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

Re: [PATCH v2 5/6] stash: default listing to "--cc --simplify-combined-diff"

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 30, 2014, 19:43 UTC
Message-ID
<xmqqtx5yy6nm.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqppgo2dqr.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 24 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> When you list stashes, you can provide arbitrary git-log
>> options to change the display. However, adding just "-p"
>> does nothing, because each stash is actually a merge commit.
>>
>> This implementation detail is easy to forget, leading to
>> confused users who think "-p" is not working. We can make
>> this easier by specifying "--cc" as a default ourselves
>> (which does nothing if no diff format is requested by the
>> user).
>
> Sigh.
>
> "git log --cc" is one of the things I wanted for a long time to fix.
> When the user explicitly asks "--cc", we currently ignore it, but
> because we know the user wants to view combined diff, we should turn
> "-p" on automatically.  And the change this patch introduces will be
> broken when we fix "log --cc" ("stash list" will end up always
> showing the patch, without a way to disable it).
>
> Can you make this conditional?  Do this only when <options> are
> given to "git stash list" command and that includes "-p" or
> something?
Perhaps something along this line?
 git-stash.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index ae73ba4..0db1b19 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -297,8 +297,15 @@ have_stash () {
 
 list_stash () {
 	have_stash || return 0
-	git log --format="%gd: %gs" -g --cc --simplify-combined-diff \
-		"$@" $ref_stash --
+	case " $* " in
+	*' --cc '*)
+		;; # the user knows what she is doing
+	*' -p '* | *' -U'*)
+		set x "--cc" "--simplify-combined-diff" "$@"
+		shift
+		;;
+	esac
+	git log --format="%gd: %gs" -g "$@" $ref_stash --
 }
 
 show_stash () {
Previous: Junio C HamanoNext: Jeff King
Message 17 of 20 in “improving "git stash list -p"”
  1. 0/2 improving "git stash list -p"Jeff King, Jul 29, 2014
  2. 1/2 add --simplify-combined-diff optionJeff King, Jul 29, 2014
  3. Jeff KingJul 29, 2014
  4. 2/2 stash: default listing to "--cc --simplify-combined-diff"Jeff King, Jul 29, 2014
  5. 3/2 stash: show combined diff with "stash show"Jeff King, Jul 29, 2014
  6. Junio C HamanoJul 29, 2014
  7. Jeff KingJul 31, 2014
  8. Junio C HamanoJul 31, 2014
  9. 0/6 improving "git stash list -p"Jeff King, Jul 29, 2014
  10. 1/6 revision: drop useless string offset when parsing "--pretty"Jeff King, Jul 29, 2014
  11. 2/6 pretty: treat "--format=" as an empty userformatJeff King, Jul 29, 2014
  12. 3/6 pretty: make empty userformats truly emptyJeff King, Jul 29, 2014
  13. 4/6 add --simplify-combined-diff optionJeff King, Jul 29, 2014
  14. Junio C HamanoJul 29, 2014
  15. 5/6 stash: default listing to "--cc --simplify-combined-diff"Jeff King, Jul 29, 2014
  16. Junio C HamanoJul 29, 2014
  17. Junio C HamanoJul 30, 2014
  18. Jeff KingJul 31, 2014
  19. Keller, Jacob EAug 12, 2014
  20. 6/6 stash: show combined diff with "stash show"Jeff King, Jul 29, 2014

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.