git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git add: respect core.filemode even with unmerged entries in the index

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 29, 2007, 08:36 UTC
Message-ID
<7vir97f98o.fsf@assigned-by-dhcp.pobox.com>
In-Reply-To
<Pine.LNX.4.64.0706281653260.4438@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 17 quoted lines
> diff --git a/read-cache.c b/read-cache.c
> index 4362b11..a74e4a7 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -382,6 +382,12 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
>  		struct cache_entry *ent;
>  		int pos = index_name_pos(istate, path, namelen);
>  
> +		/* might be unmerged */
> +		if (pos < 0 && 1-pos < istate->cache_nr &&
> +				namelen == ce_namelen(istate->cache[1-pos]) &&
> +				!memcmp(path, istate->cache[1-pos]->name,
> +					namelen))
> +			pos = 1-pos;
>  		ent = (0 <= pos) ? istate->cache[pos] : NULL;
>  		ce->ce_mode = ce_mode_from_stat(ent, st.st_mode);
>  	}
Hmph.
 * Are you sure about (1-pos)?
 * I _think_ we would want to favor our stage (i.e. #2) when
   unmerged, over other stages.  Perhaps like this:
	if (pos < 0) {
        	int a_pos = -1, our_pos = -1;
		pos = -pos-1;
		while ((pos < istate->cache_nr) &&
			namelen == ce_namelen(istate->cache[pos]) &&
			!memcmp(path, istate->cache[pos]->name, namelen))
			if (a_pos < 0)
                        	a_pos = pos;
                        if (ce_stage(istate->cache[pos]) == 2)
                        	our_pos = pos;
			pos++;
                }
		if (our_pos >= 0)
                	pos = our_pos;
		else if (a_pos >= 0)
                	pos = a_pos;
		else
                	pos = -1;
	}
	ent = (0 <= pos) ? istate->cache[pos] : NULL;
	ce->ce_mode = ce_mode_from_stat(ent, st.st_mode);
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 19 of 26 in “most commonly used git commands?”
  1. Michael S. TsirkinJun 25, 2007
  2. Junio C HamanoJun 25, 2007
  3. Michael S. TsirkinJun 25, 2007
  4. Junio C HamanoJun 25, 2007
  5. Martin LanghoffJun 28, 2007
  6. Josh TriplettJun 28, 2007
  7. Johannes SchindelinJun 25, 2007
  8. Alex RiesenJun 28, 2007
  9. Johannes SchindelinJun 28, 2007
  10. Johannes SixtJun 28, 2007
  11. Johannes SchindelinJun 28, 2007
  12. Johannes SixtJun 28, 2007
  13. Johannes SixtJun 28, 2007
  14. git add: respect core.filemode even with unmerged entries in the indexJohannes Schindelin, Jun 28, 2007
  15. Johannes SixtJun 29, 2007
  16. Johannes SchindelinJun 29, 2007
  17. Junio C HamanoJun 29, 2007
  18. git add: respect core.filemode with unmerged entriesJohannes Schindelin, Jun 29, 2007
  19. Junio C HamanoJun 29, 2007
  20. Johannes SchindelinJun 29, 2007
  21. Alex RiesenJun 30, 2007
  22. Johannes SchindelinJun 30, 2007
  23. Alex RiesenJun 30, 2007
  24. Jan HudecJul 1, 2007
  25. Alex RiesenJul 1, 2007
  26. Josh TriplettJun 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.