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

Re: [PATCH] diff: handle "-" as abbreviation of '@{-1}'

From
Javier Domingo Cansino <javierdo1@gmail.com>
Date
Mar 12, 2016, 02:48 UTC
Message-ID
<CALZVapk9seKDpLGbyJ23UVxP97WAHkdXS+U+yrJoKf-2cLamAQ@mail.gmail.com>
In-Reply-To
<1457748710-79370-1-git-send-email-senorsen.zhang@gmail.com>

dash is usually used for representing stdin / stdout as a file. I think this could drive to error... but I would agree with transforming -h1 to @{-1} or -h2 to @{-2} (-h representing head).

I do agree however that all those signs are thought with american keyboards in mind. All those punctuation marks are usually hard to type in other keyboards, and -h1 is way simpler than HEAD~ or @{-1}

This links provides an example of my worry: http://stackoverflow.com/questions/15270970/is-it-possible-to-git-diff-a-file-against-standard-input

On Sat, Mar 12, 2016 at 2:11 AM, Senorsen <senorsen.zhang@gmail.com> wrote:
Show 49 quoted lines
>
> Currently it just replace "-" in argv[] into "@{-1}".
>
> For example,
>
>     git diff -
>
> equals to
>
>     git diff @{-1}
>
> Signed-off-by: Senorsen <senorsen.zhang@gmail.com>
> ---
> Notes:
>     Hello everyone, I'm Zhang Sen, a college student from Zhejiang University
>     in China, and this is a patch for the microproject of GSoC 2016. I'm
>     looking forward to contributing to Git and participating in GSoC 2016.
>
>     I have learnt some rules and guides from the documents, and carefully
>     wrote this small patch, according to other code from git.
>
>     Thanks a lot!
>
>  builtin/diff.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/builtin/diff.c b/builtin/diff.c
> index 52c98a9..c110141 100644
> --- a/builtin/diff.c
> +++ b/builtin/diff.c
> @@ -389,6 +389,11 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
>                 }
>         }
>
> +       for (i = 0; i < argc; i++) {
> +               if (!strcmp(argv[i], "-"))
> +                       argv[i] = "@{-1}";
> +       }
> +
>         for (i = 0; i < rev.pending.nr; i++) {
>                 struct object_array_entry *entry = &rev.pending.objects[i];
>                 struct object *obj = entry->item;
> --
> 2.7.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Javier Domingo Cansino
Previous: SenorsenNext: Michael J Gruber
Message 2 of 3 in “diff: handle "-" as abbreviation of '@{-1}'”
  1. diff: handle "-" as abbreviation of '@{-1}'Senorsen, Mar 12, 2016
  2. Javier Domingo CansinoMar 12, 2016
  3. Michael J GruberMar 14, 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.