Re: how to do these 2 one-liners ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Christian MICHON" <christian.michon@xxxxxxxxx> writes:

> ================================================
> 1) how do I check the status of a single file ? ( the file is already
> added in the index)
>
> I usually use git-status here, but for single files that need update,
> there should be a faster way.

"git-diff-files $PATH" shows if it is different relative to the
index, "git-diff-index HEAD $PATH" shows if it is different from
the HEAD, and "git-diff-index --cached $PATH" shows if it is
different between index and HEAD.  git-status uses the first one
and the third one AFAIR.  You say "that need update", so
probably you are interested in seeing the first one only without
the third one.

If you have Git 1.5.1, then:

	if git diff-files --quiet $PATH
        then
        	echo Up to date
	else
        	echo Need update
	fi                

Another more portable way is:

	if test -z "$(git diff-files --raw $PATH)"
        then
        	echo Up to date
	else
        	echo Need update
	fi                

> ================================================
> 2) how do I find in historical reverse order all the commits a
> certain file belongs to since the origin ?
>
> I usually do: git-log <file> | grep ^commit
> I would like to avoid piping here...

git-rev-list -m HEAD -- "$PATH"

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]