git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Σταύρος Ντέντος" <stdedos@gmail.com>
To: git <git@vger.kernel.org>
Subject: Git alias syntax help
Date: Tue, 14 Jan 2020 17:21:20 +0200	[thread overview]
Message-ID: <CAHMHMxWpLAnj3w8DGLMFbfy-A-pBjDxNdMeiM-fyuu-gnZyg+Q@mail.gmail.com> (raw)

Hello there,

I am having an issue with git-aliases - specifically, the intricacies
involved in their syntax.

In general, the syntax is confusing to me, especially when it is
_wise_ to use quotes inside a `!sh` alias.
e.g. which one would be the correct one
new = "!f() { : git log ; git log \"${1}@{1}..${1}@{0}\" \"$@\" ; } ; f"
new = !f() { : git log ; git log "${1}@{1}..${1}@{0}" "$@" ; } ; f

(from converting this:
https://git.wiki.kernel.org/index.php/Aliases#What.27s_new.3F)
        new = !sh -c 'git log $1@{1}..$1@{0} "$@"'

The alias confusing me is more specifically this:
https://git.wiki.kernel.org/index.php/Aliases#simple_diff_ignoring_line_number_changes

diffsort = !sh -c 'git diff "$@" | grep "^[+-]" | sort --key=1.2 | uniq -u -s1'

The output of:
$  colordiff -su <(git diffsort HEAD^..HEAD) <(git diffsort HEAD^^..HEAD^)
Files /dev/fd/63 and /dev/fd/62 are identical
is a little unexpected, since I know for a fact that one of the
referced commits is not a code block moved.

(and indeed, if I do it myself:
$ colordiff -su <(git diff HEAD^..HEAD | grep "^[+-]" | sort --key=1.2
| uniq -u -s1) <(git diff HEAD^^..HEAD^ | grep "^[+-]" | sort
--key=1.2 | uniq -u -s1)
--- /dev/fd/63 2020-01-14 17:17:45.103771745 +0200
+++ /dev/fd/62 2020-01-14 17:17:45.103771745 +0200
@@ -1,2 +1,13 @@
[....]

it works.

The issue I have found is: $@ is not expanded

Tested with:

diffsort = !sh -c 'echo "+git diff $@" | grep "^[+-]" | sort --key=1.2
| uniq -u -s1'
$ git diffsort HEAD^..HEAD
+git diff

I would appreciate if someone would clear out the air for me.
I think I have done my homework enough, and it is not trivially
obvious what is the correct thing to do.

I'll gladly take pointers though

Ντέντος Σταύρος

             reply	other threads:[~2020-01-14 15:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 15:21 Σταύρος Ντέντος [this message]
2020-01-14 22:28 ` Git alias syntax help Jeff King
2020-01-14 23:13   ` Σταύρος Ντέντος
2020-01-15 18:13     ` Jeff King
2020-03-28 17:05       ` Philip Oakley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHMHMxWpLAnj3w8DGLMFbfy-A-pBjDxNdMeiM-fyuu-gnZyg+Q@mail.gmail.com \
    --to=stdedos@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).