* Git log of all (modifying) commands run on a repo? @ 2007-02-07 22:15 Bill Lear 2007-02-07 22:29 ` Jakub Narebski 2007-02-07 22:49 ` Linus Torvalds 0 siblings, 2 replies; 25+ messages in thread From: Bill Lear @ 2007-02-07 22:15 UTC (permalink / raw) To: git Our company recently switched to git. Our enthusiasm for git outweighs the problems we have encountered so far, universally those of user befuddlement, not git problems per se. I have destroyed several repos by accidentally pulling from or pushing to the wrong branch, not realizing this until later, and, trying what I thought the proper way to undo it, failed that miserably. I have destroyed a few other repos by pulling from a "polluted" repo of a co-worker that had mistakenly merged things in, and have had to resort each time to full-scale reconstructions (again, almost trivially accomplished thanks to git). Thankfully, our company repo is so far pristine, and I have been able to quickly reconstruct things and continue working. A co-worker just called to say he apparently had done something similar, as he tried to pull from our company repo, got a conflict, and then discovered files and changes to files that should not have been on the master branch. These files and changes do not exist in our company repo, of that we are certain. I'm not certain how I managed to screw up my repo, and he is equally unsure of how he managed to screw up his. I thought that it would be very useful to have a history of git commands that have been run against a repo, in order to hopefully debug this sort of thing --- perhaps only those that modify the repo. I suppose this would need to include information about which branches were affected as well. % cat .git/repo.log [....] 2007-02-07 10:05:44 git pull . ..... ** Pull from master branch onto project branch ** Pull from foobar branch onto boobar branch ** ... 2007-02-07 10:05:44 git pull git://source/project master:project ** Your explanation here... Would this sort of thing be easy to do? I presume git does not currently have support for this, but thought I would ask. Bill ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:15 Git log of all (modifying) commands run on a repo? Bill Lear @ 2007-02-07 22:29 ` Jakub Narebski 2007-02-07 22:39 ` Bill Lear 2007-02-07 22:49 ` Linus Torvalds 1 sibling, 1 reply; 25+ messages in thread From: Jakub Narebski @ 2007-02-07 22:29 UTC (permalink / raw) To: git [Cc: git@vger.kernel.org] Bill Lear wrote: > I thought that it would be very useful to have a history of git > commands that have been run against a repo, in order to hopefully > debug this sort of thing --- perhaps only those that modify the repo. > [...] > Would this sort of thing be easy to do? I presume git does not > currently have support for this, but thought I would ask. If all commands were run via git wrapper (and all scripts would use git-command version, perhaps with exception of gitweb), it would be fairly easy to do (although this should probably be repository config variable). Is history of shell commands too short? Reflogs doesn't help (concatenate all reflogs, perhaps preceding them with file name, and sort by date) either? -- Jakub Narebski Warsaw, Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:29 ` Jakub Narebski @ 2007-02-07 22:39 ` Bill Lear 2007-02-07 22:59 ` Jakub Narebski 0 siblings, 1 reply; 25+ messages in thread From: Bill Lear @ 2007-02-07 22:39 UTC (permalink / raw) To: Jakub Narebski; +Cc: git On Wednesday, February 7, 2007 at 23:29:56 (+0100) Jakub Narebski writes: >... >Is history of shell commands too short? Reflogs doesn't help >(concatenate all reflogs, perhaps preceding them with file name, >and sort by date) either? Well, I thought of shell history also, but the problem is, that we often have multiple repos on a machine (we may be executing a long-running experiment in one, for example, and not want to disturb it). Shell history in that case doesn't help. Also, not having the branch information is a minus (each of us puts the current git branch in our prompt). I didn't know about reflogs. What did you have in mind? Could you show an example, please? Bill ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:39 ` Bill Lear @ 2007-02-07 22:59 ` Jakub Narebski 0 siblings, 0 replies; 25+ messages in thread From: Jakub Narebski @ 2007-02-07 22:59 UTC (permalink / raw) To: Bill Lear; +Cc: git Bill Lear wrote: > On Wednesday, February 7, 2007 at 23:29:56 (+0100) Jakub Narebski writes: >>... >> Is history of shell commands too short? Reflogs doesn't help >> (concatenate all reflogs, perhaps preceding them with file name, >> and sort by date) either? > > Well, I thought of shell history also, but the problem is, that we often > have multiple repos on a machine (we may be executing a long-running > experiment in one, for example, and not want to disturb it). > > Shell history in that case doesn't help. Also, not having the branch > information is a minus (each of us puts the current git branch in our > prompt). Fact. Although in worst case, if shell history is deep enough, you could do forensic on it... unless you use multiple shells, freely interspersing commands in them... > I didn't know about reflogs. What did you have in mind? Could you > show an example, please? Unfortunately till some time ago reflogs were not enabled by default. If they are enabled, for each branch you should have $GIT_DIR/logs/refs/heads/<branch> file, which contains information about operations on given branch. It has pre- and post-operation commit ids, and timestamp of a change, together with short description. You could concatenate reflogs, and sort them by timestamp. Reflogs are purely local matter, they represent local view of history. See git-update-ref(1), "Logging Updates" section, git-repo-config(1) (or git-config(1)), description of core.logAllRefUpdates variable, and Git User's Manual. Examples (sha1 are shortened, and lines are broken for easier reading): * .git/logs/refs/heads/origin 798123... e68989... Jakub Narebski <jnareb@gmail.com> 1170836783 +0100 \ pull origin git://git.kernel.org/pub/scm/git/git.git: fast-forward e68989... 6506e1... Jakub Narebski <jnareb@gmail.com> 1170873620 +0100 \ fetch origin git://git.kernel.org/pub/scm/git/git.git: fast-forward * git/logs/refs/heads/master 93342d... 39daf6... Jakub Narebski <jnareb@gmail.com> 1169555797 +0100 \ commit: t/t1300-repo-config.sh: value continued on next line 39daf6... b62502... Jakub Narebski <jnareb@gmail.com> 1169809125 +0100 \ commit (merge): Merge branch 'master' of git://git.kernel.org/pub/scm/git/git b62502... 7ab704... Jakub Narebski <jnareb@gmail.com> 1170150241 +0100 \ pull origin: Merge made by recursive. 7ab704... bb77c5... Jakub Narebski <jnareb@gmail.com> 1170238531 +0100 \ pull origin: In-index merge * git/logs/refs/heads/gitweb/web ceae8a... a29878... Jakub Narebski <jnareb@gmail.com> 1169973601 +0100 \ commit: Git config file reader in Perl (WIP 5) a29878... 1b600e... Jakub Narebski <jnareb@gmail.com> 1170034498 +0100 \ reset --hard 1b600e659abc7e409c9d830e332d3cef010 62c1c1... 05b936... Jakub Narebski <jnareb@gmail.com> 1170034499 +0100 \ rebase: Git config file reader in Perl (WIP 1) -- Jakub Narebski Poland ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:15 Git log of all (modifying) commands run on a repo? Bill Lear 2007-02-07 22:29 ` Jakub Narebski @ 2007-02-07 22:49 ` Linus Torvalds 2007-02-07 22:56 ` Junio C Hamano ` (4 more replies) 1 sibling, 5 replies; 25+ messages in thread From: Linus Torvalds @ 2007-02-07 22:49 UTC (permalink / raw) To: Bill Lear; +Cc: git On Wed, 7 Feb 2007, Bill Lear wrote: > > I thought that it would be very useful to have a history of git > commands that have been run against a repo, in order to hopefully > debug this sort of thing --- perhaps only those that modify the repo. The "reflog" is kind of that, and you can literally do less .git/logs/refs/heads/master to get some kind of idea what's up. Newer gits enable reflogs by default, older gits don't (and *really* old git versions don't support it at all). Of course, we should probably just have a git reflog show command for this to make it prettier. NOTE! It's very much per-repository. When you push out your changes, your reflog stays private. Linus ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:49 ` Linus Torvalds @ 2007-02-07 22:56 ` Junio C Hamano 2007-02-07 23:03 ` Shawn O. Pearce 2007-02-07 23:26 ` Linus Torvalds 2007-02-07 22:57 ` Shawn O. Pearce ` (3 subsequent siblings) 4 siblings, 2 replies; 25+ messages in thread From: Junio C Hamano @ 2007-02-07 22:56 UTC (permalink / raw) To: Linus Torvalds; +Cc: Bill Lear, git Linus Torvalds <torvalds@linux-foundation.org> writes: > On Wed, 7 Feb 2007, Bill Lear wrote: >> >> I thought that it would be very useful to have a history of git >> commands that have been run against a repo, in order to hopefully >> debug this sort of thing --- perhaps only those that modify the repo. > > The "reflog" is kind of that, and you can literally do > > less .git/logs/refs/heads/master > > to get some kind of idea what's up. > > Newer gits enable reflogs by default, older gits don't (and *really* old > git versions don't support it at all). > > Of course, we should probably just have a > > git reflog show > > command for this to make it prettier. $ git log -g? ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:56 ` Junio C Hamano @ 2007-02-07 23:03 ` Shawn O. Pearce 2007-02-07 23:26 ` Linus Torvalds 1 sibling, 0 replies; 25+ messages in thread From: Shawn O. Pearce @ 2007-02-07 23:03 UTC (permalink / raw) To: Junio C Hamano; +Cc: Linus Torvalds, Bill Lear, git Junio C Hamano <junkio@cox.net> wrote: > $ git log -g? [git (build)]$ git log -g? fatal: unrecognized argument: -g? I think its: [git (build)]$ git log -g ? commit 6506e156d99bd406661cd5d2e502db7c0960d716 Reflog: HEAD@{0} (Shawn O. Pearce <spearce@spearce.org>) Reflog message: merge origin/master: Fast forward Author: Junio C Hamano <junkio@cox.net> ... at least with bash. :-) -- Shawn. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:56 ` Junio C Hamano 2007-02-07 23:03 ` Shawn O. Pearce @ 2007-02-07 23:26 ` Linus Torvalds 2007-02-07 23:36 ` Junio C Hamano 1 sibling, 1 reply; 25+ messages in thread From: Linus Torvalds @ 2007-02-07 23:26 UTC (permalink / raw) To: Junio C Hamano; +Cc: Bill Lear, git On Wed, 7 Feb 2007, Junio C Hamano wrote: > > > > Of course, we should probably just have a > > > > git reflog show > > > > command for this to make it prettier. > > $ git log -g? You think that is *prettier*? No, I think that if I want a log, I'll just do the "less", thank you very much ;) Linus ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:26 ` Linus Torvalds @ 2007-02-07 23:36 ` Junio C Hamano 2007-02-07 23:46 ` Linus Torvalds 0 siblings, 1 reply; 25+ messages in thread From: Junio C Hamano @ 2007-02-07 23:36 UTC (permalink / raw) To: Linus Torvalds; +Cc: git Linus Torvalds <torvalds@linux-foundation.org> writes: > On Wed, 7 Feb 2007, Junio C Hamano wrote: >> > >> > Of course, we should probably just have a >> > >> > git reflog show >> > >> > command for this to make it prettier. >> >> $ git log -g? > > You think that is *prettier*? > > No, I think that if I want a log, I'll just do the "less", thank you very > much ;) Heh, I do not care if you find "log -g" pretty, since I do not particularly find it pretty ("log --pretty=o --abbrev-commit -g" is probably prettier than "less"). I usually use "show-branch -g" myself while rewinding and rebuilding for a release, but my rewinds are lot more controlled than "oops, made a mistake" recovery schenario that triggered this discussion; for large logs (more than 25 entries) it is not very useful. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:36 ` Junio C Hamano @ 2007-02-07 23:46 ` Linus Torvalds 2007-02-07 23:53 ` Jakub Narebski ` (2 more replies) 0 siblings, 3 replies; 25+ messages in thread From: Linus Torvalds @ 2007-02-07 23:46 UTC (permalink / raw) To: Junio C Hamano; +Cc: git On Wed, 7 Feb 2007, Junio C Hamano wrote: > > Heh, I do not care if you find "log -g" pretty, since I do not > particularly find it pretty ("log --pretty=o --abbrev-commit -g" > is probably prettier than "less"). With "--pretty=oneline --abbrev-commit" I'll agree that it's actually fairly pretty. Maybe we can make "-g" default to that? As it is, I'd otherwise still use "less" just because there is less typing... Linus ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:46 ` Linus Torvalds @ 2007-02-07 23:53 ` Jakub Narebski 2007-02-07 23:59 ` Johannes Schindelin 2007-02-08 0:26 ` Junio C Hamano 2 siblings, 0 replies; 25+ messages in thread From: Jakub Narebski @ 2007-02-07 23:53 UTC (permalink / raw) To: git Linus Torvalds wrote: > On Wed, 7 Feb 2007, Junio C Hamano wrote: >> >> Heh, I do not care if you find "log -g" pretty, since I do not >> particularly find it pretty ("log --pretty=o --abbrev-commit -g" >> is probably prettier than "less"). > > With "--pretty=oneline --abbrev-commit" I'll agree that it's actually > fairly pretty. By the way, --abbrev-commit is currently not documented... -- Jakub Narebski Warsaw, Poland ShadeHawk on #git ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:46 ` Linus Torvalds 2007-02-07 23:53 ` Jakub Narebski @ 2007-02-07 23:59 ` Johannes Schindelin 2007-02-08 0:05 ` Shawn O. Pearce 2007-02-08 0:26 ` Junio C Hamano 2 siblings, 1 reply; 25+ messages in thread From: Johannes Schindelin @ 2007-02-07 23:59 UTC (permalink / raw) To: Linus Torvalds; +Cc: Junio C Hamano, git Hi, On Wed, 7 Feb 2007, Linus Torvalds wrote: > On Wed, 7 Feb 2007, Junio C Hamano wrote: > > > > Heh, I do not care if you find "log -g" pretty, since I do not > > particularly find it pretty ("log --pretty=o --abbrev-commit -g" > > is probably prettier than "less"). > > With "--pretty=oneline --abbrev-commit" I'll agree that it's actually > fairly pretty. > > Maybe we can make "-g" default to that? As it is, I'd otherwise still use > "less" just because there is less typing... I don't care either way. I'd even appreciate somebody harvesting the low-hanging fruit of making "git reflog show" a wrapper to "git log -p". Ciao, Dscho P.S.: Sorry, Shawn, but I don't think that my version "won". It was modeled after yours, but introduced flexibility to use reflog walking to other revision walkers. So, I think of it as the "next" version of your "git reflog show". ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:59 ` Johannes Schindelin @ 2007-02-08 0:05 ` Shawn O. Pearce 0 siblings, 0 replies; 25+ messages in thread From: Shawn O. Pearce @ 2007-02-08 0:05 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Linus Torvalds, Junio C Hamano, git Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > P.S.: Sorry, Shawn, but I don't think that my version "won". It was > modeled after yours, but introduced flexibility to use reflog walking to > other revision walkers. So, I think of it as the "next" version of your > "git reflog show". Don't be sorry. I think your -g reused more existing code than my `git reflog show` did, and you had the time to follow through on it when Junio was interested in a patch while I didn't. It really did win as the better solution for Git. And that's all that matters. :-) -- Shawn. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:46 ` Linus Torvalds 2007-02-07 23:53 ` Jakub Narebski 2007-02-07 23:59 ` Johannes Schindelin @ 2007-02-08 0:26 ` Junio C Hamano 2007-02-08 0:41 ` Johannes Schindelin 2 siblings, 1 reply; 25+ messages in thread From: Junio C Hamano @ 2007-02-08 0:26 UTC (permalink / raw) To: Linus Torvalds; +Cc: git Linus Torvalds <torvalds@linux-foundation.org> writes: > With "--pretty=oneline --abbrev-commit" I'll agree that it's actually > fairly pretty. > > Maybe we can make "-g" default to that? As it is, I'd otherwise still use > "less" just because there is less typing... > > Linus Well, you would not know if the user gave you '-g' before you ask setup_revisions() to parse the options, and once you let it do its thing, you would not know if it also found an explicit output format given by the end user, so your cannot sanely make default depend on '-g'. I suspect that it would have to be either somewhat involved or outright hacky. --- builtin-log.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index 982d871..0221c76 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -22,8 +22,21 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, { int i; - rev->abbrev = DEFAULT_ABBREV; rev->commit_format = CMIT_FMT_DEFAULT; + if (!strcmp(argv[0], "log")) { + /* first see if there is "-g" */ + for (i = 1; i < argc; i++) { + if (!strcmp("--", argv[i])) + break; + if (!strcmp("-g", argv[i]) || + !strcmp("--walk-reflogs", argv[i])) { + rev->abbrev_commit = 1; + rev->commit_format = CMIT_FMT_ONELINE; + break; + } + } + } + rev->abbrev = DEFAULT_ABBREV; rev->verbose_header = 1; rev->show_root_diff = default_show_root; argc = setup_revisions(argc, argv, rev, "HEAD"); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-08 0:26 ` Junio C Hamano @ 2007-02-08 0:41 ` Johannes Schindelin 2007-02-08 0:50 ` Junio C Hamano 0 siblings, 1 reply; 25+ messages in thread From: Johannes Schindelin @ 2007-02-08 0:41 UTC (permalink / raw) To: Junio C Hamano; +Cc: Linus Torvalds, git Hi, On Wed, 7 Feb 2007, Junio C Hamano wrote: > Linus Torvalds <torvalds@linux-foundation.org> writes: > > > With "--pretty=oneline --abbrev-commit" I'll agree that it's actually > > fairly pretty. > > > > Maybe we can make "-g" default to that? As it is, I'd otherwise still use > > "less" just because there is less typing... > > > > Linus > > Well, you would not know if the user gave you '-g' before you > ask setup_revisions() to parse the options, and once you let it > do its thing, you would not know if it also found an explicit > output format given by the end user, so your cannot sanely make > default depend on '-g'. > > I suspect that it would have to be either somewhat involved or > outright hacky. Well, we could always make CMIT_FMT_DEFAULT _not_be the same as _MEDIUM, and if it still is the same _after_ parsing the options, set it to MEDIUM explicitely. Same goes for the abbrev thing. Ciao, Dscho ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-08 0:41 ` Johannes Schindelin @ 2007-02-08 0:50 ` Junio C Hamano 2007-02-08 0:56 ` Johannes Schindelin 2007-02-08 17:51 ` Linus Torvalds 0 siblings, 2 replies; 25+ messages in thread From: Junio C Hamano @ 2007-02-08 0:50 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Linus Torvalds, git Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: >> Well, you would not know if the user gave you '-g' before you >> ask setup_revisions() to parse the options, and once you let it >> do its thing, you would not know if it also found an explicit >> output format given by the end user, so your cannot sanely make >> default depend on '-g'. >> >> I suspect that it would have to be either somewhat involved or >> outright hacky. > > Well, we could always make CMIT_FMT_DEFAULT _not_be the same as _MEDIUM, > and if it still is the same _after_ parsing the options, set it to MEDIUM > explicitely. Same goes for the abbrev thing. I think we are in agreement. I showed an outright hacky one because I am not ready to do somewhat involved one at the end of the rc period. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-08 0:50 ` Junio C Hamano @ 2007-02-08 0:56 ` Johannes Schindelin 2007-02-08 17:51 ` Linus Torvalds 1 sibling, 0 replies; 25+ messages in thread From: Johannes Schindelin @ 2007-02-08 0:56 UTC (permalink / raw) To: Junio C Hamano; +Cc: Linus Torvalds, git Hi, On Wed, 7 Feb 2007, Junio C Hamano wrote: > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > > >> Well, you would not know if the user gave you '-g' before you > >> ask setup_revisions() to parse the options, and once you let it > >> do its thing, you would not know if it also found an explicit > >> output format given by the end user, so your cannot sanely make > >> default depend on '-g'. > >> > >> I suspect that it would have to be either somewhat involved or > >> outright hacky. > > > > Well, we could always make CMIT_FMT_DEFAULT _not_be the same as _MEDIUM, > > and if it still is the same _after_ parsing the options, set it to MEDIUM > > explicitely. Same goes for the abbrev thing. > > I think we are in agreement. I showed an outright hacky one > because I am not ready to do somewhat involved one at the end of > the rc period. I fully agree. That's also why I am not pressing on other changes. Ciao, Dscho ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-08 0:50 ` Junio C Hamano 2007-02-08 0:56 ` Johannes Schindelin @ 2007-02-08 17:51 ` Linus Torvalds 2007-02-08 18:36 ` Johannes Schindelin 1 sibling, 1 reply; 25+ messages in thread From: Linus Torvalds @ 2007-02-08 17:51 UTC (permalink / raw) To: Junio C Hamano; +Cc: Johannes Schindelin, git On Wed, 7 Feb 2007, Junio C Hamano wrote: > > I think we are in agreement. I showed an outright hacky one > because I am not ready to do somewhat involved one at the end of > the rc period. How about this? It makes "git reflog [show]" act as git log -g --pretty=oneline --abbrev-cmit and is fairly straightforward. So you can just write git reflog or git reflog show and it will show you the reflog in a nice format. Linus --- Documentation/git-reflog.txt | 17 +++++++++++++---- builtin-log.c | 32 ++++++++++++++++++++++++++++++++ builtin-reflog.c | 18 ++++++++++++------ builtin.h | 1 + 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt index 1138865..bc7c987 100644 --- a/Documentation/git-reflog.txt +++ b/Documentation/git-reflog.txt @@ -8,13 +8,18 @@ git-reflog - Manage reflog information SYNOPSIS -------- -[verse] -'git-reflog' expire [--dry-run] [--stale-fix] - [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>... - +'git reflog' <subcommand> <options> DESCRIPTION ----------- +The command takes various subcommands, and different options +depending on the subcommand: + +[verse] +git reflog expire [--dry-run] [--stale-fix] + [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>... + +git reflog [show] [log-options] Reflog is a mechanism to record when the tip of branches are updated. This command is to manage the information recorded in it. @@ -25,6 +30,10 @@ Entries older than `expire` time, or entries older than tip, are removed from the reflog. This is typically not used directly by the end users -- instead, see gitlink:git-gc[1]. +The subcommand "show" (which is also the default, in the absense of any +subcommands) will take all the normal log options, and show the log of +the current branch. It is basically an alias for 'git log -g --abbrev-commit +--pretty=oneline', see gitlink:git-log[1]. OPTIONS diff --git a/builtin-log.c b/builtin-log.c index 982d871..af2de54 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -11,6 +11,7 @@ #include "log-tree.h" #include "builtin.h" #include "tag.h" +#include "reflog-walk.h" static int default_show_root = 1; @@ -181,6 +182,37 @@ int cmd_show(int argc, const char **argv, const char *prefix) return ret; } +/* + * This is equivalent to "git log -g --abbrev-commit --pretty=oneline" + */ +int cmd_log_reflog(int argc, const char **argv, const char *prefix) +{ + struct rev_info rev; + + git_config(git_log_config); + init_revisions(&rev, prefix); + init_reflog_walk(&rev.reflog_info); + rev.abbrev_commit = 1; + rev.verbose_header = 1; + cmd_log_init(argc, argv, prefix, &rev); + + /* + * This means that we override whatever commit format the user gave + * on the cmd line. Sad, but cmd_log_init() currently doesn't + * allow us to set a different default. + */ + rev.commit_format = CMIT_FMT_ONELINE; + rev.always_show_header = 1; + + /* + * We get called through "git reflog", so unlike the other log + * routines, we need to set up our pager manually.. + */ + setup_pager(); + + return cmd_log_walk(&rev); +} + int cmd_log(int argc, const char **argv, const char *prefix) { struct rev_info rev; diff --git a/builtin-reflog.c b/builtin-reflog.c index bfb169a..65b845b 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -13,7 +13,7 @@ */ static const char reflog_expire_usage[] = -"git-reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>..."; +"git-reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>..."; static unsigned long default_reflog_expire; static unsigned long default_reflog_expire_unreachable; @@ -372,10 +372,16 @@ static const char reflog_usage[] = int cmd_reflog(int argc, const char **argv, const char *prefix) { - if (argc < 2) - usage(reflog_usage); - else if (!strcmp(argv[1], "expire")) + /* With no command, we default to showing it. */ + if (argc < 2 || *argv[1] == '-') + return cmd_log_reflog(argc, argv, prefix); + + if (!strcmp(argv[1], "show")) + return cmd_log_reflog(argc - 1, argv + 1, prefix); + + if (!strcmp(argv[1], "expire")) return cmd_reflog_expire(argc - 1, argv + 1, prefix); - else - usage(reflog_usage); + + /* Not a recognized reflog command..*/ + usage(reflog_usage); } diff --git a/builtin.h b/builtin.h index dd0e352..5108fd2 100644 --- a/builtin.h +++ b/builtin.h @@ -40,6 +40,7 @@ extern int cmd_grep(int argc, const char **argv, const char *prefix); extern int cmd_help(int argc, const char **argv, const char *prefix); extern int cmd_init_db(int argc, const char **argv, const char *prefix); extern int cmd_log(int argc, const char **argv, const char *prefix); +extern int cmd_log_reflog(int argc, const char **argv, const char *prefix); extern int cmd_ls_files(int argc, const char **argv, const char *prefix); extern int cmd_ls_tree(int argc, const char **argv, const char *prefix); extern int cmd_mailinfo(int argc, const char **argv, const char *prefix); ^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-08 17:51 ` Linus Torvalds @ 2007-02-08 18:36 ` Johannes Schindelin 0 siblings, 0 replies; 25+ messages in thread From: Johannes Schindelin @ 2007-02-08 18:36 UTC (permalink / raw) To: Linus Torvalds; +Cc: Junio C Hamano, git Hi, On Thu, 8 Feb 2007, Linus Torvalds wrote: > On Wed, 7 Feb 2007, Junio C Hamano wrote: > > > > I think we are in agreement. I showed an outright hacky one > > because I am not ready to do somewhat involved one at the end of > > the rc period. > > How about this? > > [...] > > Documentation/git-reflog.txt | 17 +++++++++++++---- Wow: documentation by Linus! ;-) > diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt > diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt Not using commit & format-patch? > index 1138865..bc7c987 100644 > --- a/Documentation/git-reflog.txt > +++ b/Documentation/git-reflog.txt > @@ -8,13 +8,18 @@ git-reflog - Manage reflog information > > SYNOPSIS > -------- > -[verse] > -'git-reflog' expire [--dry-run] [--stale-fix] > - [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>... > - > +'git reflog' <subcommand> <options> This line has white space at the end. Besides those (TIC) comments, I also have this one: Looks good to me! Ciao, Dscho ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:49 ` Linus Torvalds 2007-02-07 22:56 ` Junio C Hamano @ 2007-02-07 22:57 ` Shawn O. Pearce 2007-02-07 23:00 ` Bill Lear ` (2 subsequent siblings) 4 siblings, 0 replies; 25+ messages in thread From: Shawn O. Pearce @ 2007-02-07 22:57 UTC (permalink / raw) To: Linus Torvalds; +Cc: Bill Lear, git Linus Torvalds <torvalds@linux-foundation.org> wrote: > Of course, we should probably just have a > > git reflog show > > command for this to make it prettier. I tried that (I submitted patches to create `git reflog show`). Dscho's `git log -g` was the better candidate, and won. Its already in git.git's master branch. -- Shawn. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:49 ` Linus Torvalds 2007-02-07 22:56 ` Junio C Hamano 2007-02-07 22:57 ` Shawn O. Pearce @ 2007-02-07 23:00 ` Bill Lear 2007-02-07 23:29 ` Linus Torvalds 2007-02-07 23:02 ` Linus Torvalds 2007-02-08 8:26 ` Johannes Sixt 4 siblings, 1 reply; 25+ messages in thread From: Bill Lear @ 2007-02-07 23:00 UTC (permalink / raw) To: Linus Torvalds; +Cc: git On Wednesday, February 7, 2007 at 14:49:50 (-0800) Linus Torvalds writes: >... >The "reflog" is kind of that, and you can literally do > > less .git/logs/refs/heads/master > >to get some kind of idea what's up. > >Newer gits enable reflogs by default, older gits don't (and *really* old >git versions don't support it at all). Ah, I don't seem to have .git/logs at all. We plan to upgrade to 1.5 when it's out, so I guess we'll just have to wait. Bill ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:00 ` Bill Lear @ 2007-02-07 23:29 ` Linus Torvalds 2007-02-07 23:31 ` Bill Lear 0 siblings, 1 reply; 25+ messages in thread From: Linus Torvalds @ 2007-02-07 23:29 UTC (permalink / raw) To: Bill Lear; +Cc: git On Wed, 7 Feb 2007, Bill Lear wrote: > > Ah, I don't seem to have .git/logs at all. > > We plan to upgrade to 1.5 when it's out, so I guess we'll just > have to wait. Even with the git you have, you can probably just do a git repo-config --global core.logallrefupdates true and you'll have reflogs enabled for all of your repositories (well, at least the ones that share that home directory and thus ~/.gitconfig) Linus ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 23:29 ` Linus Torvalds @ 2007-02-07 23:31 ` Bill Lear 0 siblings, 0 replies; 25+ messages in thread From: Bill Lear @ 2007-02-07 23:31 UTC (permalink / raw) To: Linus Torvalds; +Cc: git On Wednesday, February 7, 2007 at 15:29:40 (-0800) Linus Torvalds writes: >... >Even with the git you have, you can probably just do a > > git repo-config --global core.logallrefupdates true > >and you'll have reflogs enabled for all of your repositories (well, at >least the ones that share that home directory and thus ~/.gitconfig) Ok, this is good to know, thank you. Bill ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:49 ` Linus Torvalds ` (2 preceding siblings ...) 2007-02-07 23:00 ` Bill Lear @ 2007-02-07 23:02 ` Linus Torvalds 2007-02-08 8:26 ` Johannes Sixt 4 siblings, 0 replies; 25+ messages in thread From: Linus Torvalds @ 2007-02-07 23:02 UTC (permalink / raw) To: Bill Lear; +Cc: git On Wed, 7 Feb 2007, Linus Torvalds wrote: > > Newer gits enable reflogs by default [...] This, btw, is only true for non-bare ones. In particular, if you only _push_ to a repository, it won't have reflogs enabled by default, because pushing is a "bare git" action even if it actually has a working tree (because the push will ignore the working tree and enter the ".git" directory itself). So even with new git, if you want to have reflogs enabled for shared repositories that people push to (as opposed to the individual *developer* repositories), you need to enable reflogs by hand (either in the git config file, or by just creating the empty log file). Linus ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Git log of all (modifying) commands run on a repo? 2007-02-07 22:49 ` Linus Torvalds ` (3 preceding siblings ...) 2007-02-07 23:02 ` Linus Torvalds @ 2007-02-08 8:26 ` Johannes Sixt 4 siblings, 0 replies; 25+ messages in thread From: Johannes Sixt @ 2007-02-08 8:26 UTC (permalink / raw) To: git Linus Torvalds wrote: > > On Wed, 7 Feb 2007, Bill Lear wrote: > > > > I thought that it would be very useful to have a history of git > > commands that have been run against a repo, in order to hopefully > > debug this sort of thing --- perhaps only those that modify the repo. > > The "reflog" is kind of that, and you can literally do > > less .git/logs/refs/heads/master > > to get some kind of idea what's up. Or something like this: find .git/logs -type f | xargs cat | sort -t'>' -k2 -n | less -- Hannes ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2007-02-08 18:37 UTC | newest] Thread overview: 25+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-02-07 22:15 Git log of all (modifying) commands run on a repo? Bill Lear 2007-02-07 22:29 ` Jakub Narebski 2007-02-07 22:39 ` Bill Lear 2007-02-07 22:59 ` Jakub Narebski 2007-02-07 22:49 ` Linus Torvalds 2007-02-07 22:56 ` Junio C Hamano 2007-02-07 23:03 ` Shawn O. Pearce 2007-02-07 23:26 ` Linus Torvalds 2007-02-07 23:36 ` Junio C Hamano 2007-02-07 23:46 ` Linus Torvalds 2007-02-07 23:53 ` Jakub Narebski 2007-02-07 23:59 ` Johannes Schindelin 2007-02-08 0:05 ` Shawn O. Pearce 2007-02-08 0:26 ` Junio C Hamano 2007-02-08 0:41 ` Johannes Schindelin 2007-02-08 0:50 ` Junio C Hamano 2007-02-08 0:56 ` Johannes Schindelin 2007-02-08 17:51 ` Linus Torvalds 2007-02-08 18:36 ` Johannes Schindelin 2007-02-07 22:57 ` Shawn O. Pearce 2007-02-07 23:00 ` Bill Lear 2007-02-07 23:29 ` Linus Torvalds 2007-02-07 23:31 ` Bill Lear 2007-02-07 23:02 ` Linus Torvalds 2007-02-08 8:26 ` Johannes Sixt
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).