Skip to content
Snippets Groups Projects
Select Git revision
  • pu
  • passt default
  • master
  • todo
  • next
  • maint
  • v2.8.0-rc1
  • v2.8.0-rc0
  • v2.7.2
  • v2.7.1
  • v2.7.0
  • v2.6.5
  • v2.7.0-rc3
  • v2.7.0-rc2
  • v2.7.0-rc1
  • v2.7.0-rc0
  • v2.6.4
  • v2.6.3
  • v2.6.2
  • v2.6.1
  • v2.3.10
  • v2.5.4
  • v2.4.10
  • v2.6.0
  • v2.6.0-rc3
  • v2.5.3
26 results

diffcore-break.c

Blame
  • diff-no-index.c 6.91 KiB
    /*
     * "diff --no-index" support
     * Copyright (c) 2007 by Johannes Schindelin
     * Copyright (c) 2008 by Junio C Hamano
     */
    
    #include "cache.h"
    #include "color.h"
    #include "commit.h"
    #include "blob.h"
    #include "tag.h"
    #include "diff.h"
    #include "diffcore.h"
    #include "revision.h"
    #include "log-tree.h"
    #include "builtin.h"
    #include "string-list.h"
    #include "dir.h"
    
    static int read_directory_contents(const char *path, struct string_list *list)
    {
    	DIR *dir;
    	struct dirent *e;
    
    	if (!(dir = opendir(path)))
    		return error("Could not open directory %s", path);
    
    	while ((e = readdir(dir)))
    		if (!is_dot_or_dotdot(e->d_name))
    			string_list_insert(list, e->d_name);
    
    	closedir(dir);
    	return 0;
    }
    
    /*
     * This should be "(standard input)" or something, but it will
     * probably expose many more breakages in the way no-index code
     * is bolted onto the diff callchain.
     */
    static const char file_from_standard_input[] = "-";
    
    static int get_mode(const char *path, int *mode)
    {
    	struct stat st;
    
    	if (!path || !strcmp(path, "/dev/null"))
    		*mode = 0;
    #ifdef GIT_WINDOWS_NATIVE
    	else if (!strcasecmp(path, "nul"))
    		*mode = 0;
    #endif
    	else if (path == file_from_standard_input)
    		*mode = create_ce_mode(0666);
    	else if (lstat(path, &st))
    		return error("Could not access '%s'", path);
    	else
    		*mode = st.st_mode;
    	return 0;
    }
    
    static int populate_from_stdin(struct diff_filespec *s)
    {
    	struct strbuf buf = STRBUF_INIT;
    	size_t size = 0;
    
    	if (strbuf_read(&buf, 0, 0) < 0)
    		return error("error while reading from stdin %s",
    				     strerror(errno));