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

Re: [PATCH] blame: Allow to blame paths freshly added to the index

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 15, 2016, 10:45 UTC
Message-ID
<alpine.DEB.2.20.1607151242020.6426@virtualbox>
In-Reply-To
<20160715024254.29186-1-mh@glandium.org>
Hi Mike,
On Fri, 15 Jul 2016, Mike Hommey wrote:
Show 12 quoted lines
> When blaming files, changes in the work tree are taken into account
> and displayed as being "Not Committed Yet".
> 
> However, when blaming a file that is not known to the current HEAD,
> git blame fails with `no such path 'foo' in HEAD`, even when the file
> was git add'ed.
> 
> This would seem uninteresting with the plain `git blame` case, which
> it is, but it becomes useful when using copy detection, and the new file
> was created from pieces already in HEAD, moved or copied from other
> files.
> ---
Well explained.
Please add your sign-off.
Show 18 quoted lines
>  static struct commit_list **append_parent(struct commit_list **tail, const unsigned char *sha1)
> diff --git a/t/t8003-blame-corner-cases.sh b/t/t8003-blame-corner-cases.sh
> index a9b266f..a0a09e2 100755
> --- a/t/t8003-blame-corner-cases.sh
> +++ b/t/t8003-blame-corner-cases.sh
> @@ -137,6 +137,29 @@ test_expect_success 'blame wholesale copy and more' '
>  
>  '
>  
> +test_expect_success 'blame wholesale copy and more in the index' '
> +
> +	{
> +		echo ABC
> +		echo DEF
> +		echo XXXX
> +		echo YYYY
> +		echo GHIJK
> +	} >horse &&

A more common way to do this in our test scripts is by using here documents. However, in this case I would suggest

	test_write_lines ABC DEF XXXX YYYY GHIJK >horse
instead. The equivalent applies to the 'expected' file below:
Show 11 quoted lines
> +	git add horse &&
> +	git blame -f -C -C1 -- horse | sed -e "$pick_fc" >current &&
> +	{
> +		echo mouse-Initial
> +		echo mouse-Second
> +		echo cow-Fifth
> +		echo horse-Not
> +		echo mouse-Third
> +	} >expected &&
> +	test_cmp expected current &&
> +	git rm -f horse
Should this not be a
	test_when_finished "git rm -f horse"
at the beginning?
Otherwise it looks really good to me.

Ciao, Dscho

Previous: Mike HommeyNext: Mike Hommey
Message 2 of 15 in “blame: Allow to blame paths freshly added to the index”
  1. blame: Allow to blame paths freshly added to the indexMike Hommey, Jul 15, 2016
  2. Johannes SchindelinJul 15, 2016
  3. Mike HommeyJul 15, 2016
  4. Jeff KingJul 15, 2016
  5. Mike HommeyJul 15, 2016
  6. blame: Allow to blame paths freshly added to the indexMike Hommey, Jul 15, 2016
  7. Johannes SchindelinJul 15, 2016
  8. Junio C HamanoJul 15, 2016
  9. Junio C HamanoJul 15, 2016
  10. Mike HommeyJul 15, 2016
  11. Junio C HamanoJul 18, 2016
  12. 1/2 blame: Allow to blame paths freshly added to the indexMike Hommey, Jul 15, 2016
  13. 2/2 t/t8003-blame-corner-cases.sh: Use here documentsMike Hommey, Jul 15, 2016
  14. Johannes SchindelinJul 16, 2016
  15. Junio C HamanoJul 18, 2016

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.