git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Reference to a commit inside a commit message
@ 2014-04-28 18:35 enzodicicco
  2014-04-28 19:55 ` Jonathan Nieder
  2014-04-29  3:41 ` Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: enzodicicco @ 2014-04-28 18:35 UTC (permalink / raw)
  To: git

Hi to all, I'm trying to figure out what is the best way (and if it exists) to link a message of a commit to another commit.
I start by saying I don't know Git very well so maybe this question can be very trival for someone but I've googled and searched into the Mailing List with little success.

The goal would be to be able to refer to a specific commit (or a set of it) through its Hash in order to justify some actions done in a commit, mantaining the message compact.

Obviously I don't mean to put the raw Hash, rather I would be happy to find a way to automatize the visits and the insertions of the commits inside the message.

What I mean is  what Gitweb do, naturally adapted for the use of Git through shell.

For example, thinking about it, I've imagined to add this feature to `git commit`:

    git commit --see-also <commit1> <commit2> ...

that adds a label (like "Signed-off-by") such as:

    See-also:
        1: <commit 1>
        2: <commit 2>
        ...

And, to other side, `git show` could have a feature like this:

    git show <commit> --see-also 1

that simply call `git show <commit-1>`.

So, there is a better way to obtain a behaviour like this?
Has ever been discussed the possibility of implementing a similar feature? and There is a way to handle a similar behaviour through Hooks?

Thanks to all,
NaN

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Reference to a commit inside a commit message
  2014-04-28 18:35 Reference to a commit inside a commit message enzodicicco
@ 2014-04-28 19:55 ` Jonathan Nieder
  2014-04-28 20:43   ` Vincenzo di Cicco
  2014-04-29  3:41 ` Jeff King
  1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Nieder @ 2014-04-28 19:55 UTC (permalink / raw)
  To: enzodicicco; +Cc: git

Hi,

enzodicicco@gmail.com wrote:

> Hi to all, I'm trying to figure out what is the best way (and if it
> exists) to link a message of a commit to another commit.
[...]
> Obviously I don't mean to put the raw Hash,

Why not?

See the output of

	git log --grep='In commit '

and

	git log --grep='In v'

in git.git or linux.git for some examples of current practice.

Curious,
Jonathan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Reference to a commit inside a commit message
  2014-04-28 19:55 ` Jonathan Nieder
@ 2014-04-28 20:43   ` Vincenzo di Cicco
  0 siblings, 0 replies; 7+ messages in thread
From: Vincenzo di Cicco @ 2014-04-28 20:43 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Git List

Thank you very much

> Why not?

the reason is to avoid mistakes with the hash. An automatic approach
can verify the existence of the commit.

> See the output of
>
>         git log --grep='In commit '
>
> and
>
>         git log --grep='In v'

I've just tried the commands and noticed that this can be a common practice.
This increases my curiosity to know if there is a better way to handle
this situation, if you know other thread where was discussed, please
tell me the link.

Thanks,
NaN

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Reference to a commit inside a commit message
  2014-04-28 18:35 Reference to a commit inside a commit message enzodicicco
  2014-04-28 19:55 ` Jonathan Nieder
@ 2014-04-29  3:41 ` Jeff King
  2014-04-29  7:57   ` Felipe Contreras
  1 sibling, 1 reply; 7+ messages in thread
From: Jeff King @ 2014-04-29  3:41 UTC (permalink / raw)
  To: git

On Mon, Apr 28, 2014 at 08:35:52PM +0200, enzodicicco@gmail.com wrote:

> For example, thinking about it, I've imagined to add this feature to `git commit`:
> 
>     git commit --see-also <commit1> <commit2> ...

Jonathan mentioned already that we typically just do this by hand[1],
though look on the list for the "interpret-trailers" work being done by
Christian. It would make it very easy to add:

  See-also: ....

lines to the bottom of your commit using a command like the above. I
don't know if it would be easy to convert refnames into commit ids with
it or not. You'd have to look.

-Peff

[1] I do not know about others, but I typically cut and paste from
    another terminal, and use the following alias in my config:

      [alias]
      ll = "!git --no-pager log -1 --pretty='tformat:%h (%s, %ad)' --date=short"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Reference to a commit inside a commit message
  2014-04-29  3:41 ` Jeff King
@ 2014-04-29  7:57   ` Felipe Contreras
  2014-04-29 23:23     ` Vincenzo di Cicco
  0 siblings, 1 reply; 7+ messages in thread
From: Felipe Contreras @ 2014-04-29  7:57 UTC (permalink / raw)
  To: Jeff King, git

Jeff King wrote:

> [1] I do not know about others, but I typically cut and paste from
>     another terminal, and use the following alias in my config:
> 
>       [alias]
>       ll = "!git --no-pager log -1 --pretty='tformat:%h (%s, %ad)' --date=short"

I have:

  [alias]
  short = show --quiet --format='%C(auto)%h (%s)%C(reset)'

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Reference to a commit inside a commit message
  2014-04-29  7:57   ` Felipe Contreras
@ 2014-04-29 23:23     ` Vincenzo di Cicco
       [not found]       ` <CAP8UFD1q2zdJZVkJVsNtGfN35LFmuK5txd91nTak5kGmvvKdWA@mail.gmail.com>
  0 siblings, 1 reply; 7+ messages in thread
From: Vincenzo di Cicco @ 2014-04-29 23:23 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Jeff King, Git List

Thanks to all.
With interpret-trailers has been easy to make a simple script, also it
checks if the Hash passed is a valid Object.
I haven't found a simple way to mantain the blank line above the
output of interpet-trailers (not even through cleanup).
Follows the script, maybe could be usefull for somebody:

#!/bin/sh
for i in $*
do
    git show $i &> /dev/null
    if [ $? = 0 ]
    then
        trailers+=" see-also=$i"
    fi
done

msg=$(cat /dev/null | ../git-interpret-trailers $trailers)

git commit -m "$msg" -e

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Reference to a commit inside a commit message
       [not found]       ` <CAP8UFD1q2zdJZVkJVsNtGfN35LFmuK5txd91nTak5kGmvvKdWA@mail.gmail.com>
@ 2014-04-30 18:29         ` Vincenzo di Cicco
  0 siblings, 0 replies; 7+ messages in thread
From: Vincenzo di Cicco @ 2014-04-30 18:29 UTC (permalink / raw)
  To: Christian Couder; +Cc: Felipe Contreras, Jeff King, Git List

> You should use the latest version of the patch series (v11), because the
> blank line is now automatically added.

Yes interpret-trailers add the blank line, but when call `git commit
-m "$MSG" -e` it isn't displayed.
I think this happens due to the default value of 'cleanup' option of
git-commit that is 'strip' (in my case) when the message is edited.
I can't use neither 'verbatim' nor 'whitespace' otherwise all the
comments will be displayed.

> And using ':' instead of '=' after "see-also" would be more standard.

Thanks I've updated my script and now I'm using the latest interpret-trailers.

NaN

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-04-30 18:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-28 18:35 Reference to a commit inside a commit message enzodicicco
2014-04-28 19:55 ` Jonathan Nieder
2014-04-28 20:43   ` Vincenzo di Cicco
2014-04-29  3:41 ` Jeff King
2014-04-29  7:57   ` Felipe Contreras
2014-04-29 23:23     ` Vincenzo di Cicco
     [not found]       ` <CAP8UFD1q2zdJZVkJVsNtGfN35LFmuK5txd91nTak5kGmvvKdWA@mail.gmail.com>
2014-04-30 18:29         ` Vincenzo di Cicco

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 NNTP newsgroup(s).