In SVN, doing svn update will show a list of full paths with a status prefix:

$ svn update
M foo/bar
U another/bar
Revision 123

I need to get this update list to do some post-process work. After I have transferred the SVN repository to Git, I can't find a way to get the update list:

$ git pull
Updating 9607ca4..61584c3
Fast-forward
 .gitignore                                         |    1 +
 uni/.gitignore                                     |    1 +
 uni/package/cooldeb/.gitignore                     |    1 +
 uni/package/cooldeb/Makefile.am                    |    2 +-
 uni/package/cooldeb/VERSION.av                     |   10 +-
 uni/package/cooldeb/cideb                          |   10 +-
 uni/package/cooldeb/cooldeb.sh                     |    2 +-
 uni/package/cooldeb/newdeb                         |   53 +++-
 ...update-and-deb-redist => update-and-deb-redist} |    5 +-
 uni/utils/2tree/{list2tree => 2tree}               |   12 +-
 uni/utils/2tree/ChangeLog                          |    4 +-
 uni/utils/2tree/Makefile.am                        |    2 +-

I can translate the Git pull status list to SVN's format:

M .gitignore
M uni/.gitignore
M uni/package/cooldeb/.gitignore
M uni/package/cooldeb/Makefile.am
M uni/package/cooldeb/VERSION.av
M uni/package/cooldeb/cideb
M uni/package/cooldeb/cooldeb.sh
M uni/package/cooldeb/newdeb
M ...update-and-deb-redist => update-and-deb-redist}
M uni/utils/2tree/{list2tree => 2tree}
M uni/utils/2tree/ChangeLog
M uni/utils/2tree/Makefile.am

However, some entries having long path names are abbreviated, such as uni/package/cooldeb/update-and-deb-redist is abbreviated to ...update-and-deb-redist.

I deem I can do with Git directly, maybe I can configure git pull's output in special format.

Any idea?

EDIT

I've figured out a resolution to this:

First, save the last and current commit to variable PREV and NEXT:

$ PREV=`git show --format=format:%H --summary | head -1`
$ git pull
$ NEXT=`git show --format=format:%H --summary | head -1`

And then, compare the two commit using special format:

$ git diff --name-status $PREV $NEXT

This will give the output:

A       .gitignore
M       uni/.gitignore
A       uni/package/cooldeb/.gitignore
M       uni/package/cooldeb/Makefile.am
M       uni/package/cooldeb/VERSION.av
M       uni/package/cooldeb/cideb
M       uni/package/cooldeb/cooldeb.sh
...

Which is exactly the same as Subversion's.

Then, it's also easy to make it in preview mode:

$ PREV=`git show --format=format:%H --summary | head -1`
$ git stash
$ git pull
$ NEXT=`git show --format=format:%H --summary | head -1`
$ git diff --name-status $PREV $NEXT
$ git reset --hard $PREV
$ git stash pop
link|improve this question

Are you tying to "show what will be updated next pull" (title of your question or convert git pull to SVN's format? – Aleksandr Levchuk Jan 5 '11 at 23:44
I'm trying to show what will be updated next pull. The exactly path names is just enough. – Xie Jilei Jan 5 '11 at 23:46
Unfortunately, git pull -v doesn't get the full pathnames. – Xie Jilei Jan 5 '11 at 23:47
It's strange, actually git pull --no-commit do commit anyway. – Xie Jilei Jan 5 '11 at 23:58
1  
I'm not sure why you need the full paths here - I understand your title question a bit differently, but if you already ran git pull then you can see the full path like this git log --stat --raw -n 1 - this will show the last commit files in raw format (to avoid opening less use git --no-pager ...) – Aleksandr Levchuk Jan 6 '11 at 0:25
show 1 more comment
feedback

1 Answer

up vote 2 down vote accepted

The first option of man git-pull is:

   --no-commit

       With --no-commit perform the merge but pretend the merge failed and
       do not autocommit, to give the user a chance to inspect and further
       tweak the merge result before committing.

So use git pull --no-commit.

EDIT: Oops! This does not work. As 谢继雷 (question's author) pointed out git pull --no-commit will still commit. I'm using git version 1.7.0.4.

If you don't what the changes that got pulled in, then there is a way to go back:

git branch bad-branch-1
git log                          # Find the point you want to restore to,
                                 # for example: 35da5f07ca2c5

git reset --hard 35da5f07ca2c5   # Rolls back history and files
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.