summaryrefslogtreecommitdiff
path: root/builtin-reflog.c
Commit message (Collapse)AuthorAgeFilesLines
* Move 'builtin-*' into a 'builtin/' subdirectoryLinus Torvalds2010-02-221-719/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This shrinks the top-level directory a bit, and makes it much more pleasant to use auto-completion on the thing. Instead of [torvalds@nehalem git]$ em buil<tab> Display all 180 possibilities? (y or n) [torvalds@nehalem git]$ em builtin-sh builtin-shortlog.c builtin-show-branch.c builtin-show-ref.c builtin-shortlog.o builtin-show-branch.o builtin-show-ref.o [torvalds@nehalem git]$ em builtin-shor<tab> builtin-shortlog.c builtin-shortlog.o [torvalds@nehalem git]$ em builtin-shortlog.c you get [torvalds@nehalem git]$ em buil<tab> [type] builtin/ builtin.h [torvalds@nehalem git]$ em builtin [auto-completes to] [torvalds@nehalem git]$ em builtin/sh<tab> [type] shortlog.c shortlog.o show-branch.c show-branch.o show-ref.c show-ref.o [torvalds@nehalem git]$ em builtin/sho [auto-completes to] [torvalds@nehalem git]$ em builtin/shor<tab> [type] shortlog.c shortlog.o [torvalds@nehalem git]$ em builtin/shortlog.c which doesn't seem all that different, but not having that annoying break in "Display all 180 possibilities?" is quite a relief. NOTE! If you do this in a clean tree (no object files etc), or using an editor that has auto-completion rules that ignores '*.o' files, you won't see that annoying 'Display all 180 possibilities?' message - it will just show the choices instead. I think bash has some cut-off around 100 choices or something. So the reason I see this is that I'm using an odd editory, and thus don't have the rules to cut down on auto-completion. But you can simulate that by using 'ls' instead, or something similar. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Let 'git <command> -h' show usage without a git dirJonathan Nieder2009-11-101-0/+3
| | | | | | | | | | There is no need for "git <command> -h" to depend on being inside a repository. Reported by Gerfried Fuchs through http://bugs.debian.org/462557 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* use write_str_in_full helper to avoid literal string lengthsJim Meyering2009-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 2d14d65 (Use a clearer style to issue commands to remote helpers, 2009-09-03) I happened to notice two changes like this: - write_in_full(helper->in, "list\n", 5); + + strbuf_addstr(&buf, "list\n"); + write_in_full(helper->in, buf.buf, buf.len); + strbuf_reset(&buf); IMHO, it would be better to define a new function, static inline ssize_t write_str_in_full(int fd, const char *str) { return write_in_full(fd, str, strlen(str)); } and then use it like this: - strbuf_addstr(&buf, "list\n"); - write_in_full(helper->in, buf.buf, buf.len); - strbuf_reset(&buf); + write_str_in_full(helper->in, "list\n"); Thus not requiring the added allocation, and still avoiding the maintenance risk of literal string lengths. These days, compilers are good enough that strlen("literal") imposes no run-time cost. Transformed via this: perl -pi -e \ 's/write_in_full\((.*?), (".*?"), \d+\)/write_str_in_full($1, $2)/'\ $(git grep -l 'write_in_full.*"') Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Better usage string for reflog.Matthieu Moy2009-08-051-1/+1
| | | | | Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix more typos/spelling in commentsMichael J Gruber2009-04-221-1/+1
| | | | | | | A few more fixes on top of the automatic spell checker generated ones. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix typos / spelling in commentsMike Ralphson2009-04-221-1/+1
| | | | | Signed-off-by: Mike Ralphson <mike@abacus.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Speed up reflog pruning of unreachable commitsJunio Hamano2009-04-011-0/+44
| | | | | | | | | | | Instead of doing the (potentially very expensive) "in_merge_base()" check for each commit that might be pruned if it is unreachable, do a preparatory reachability graph of the commit space, so that the common case of being reachable can be tested directly. [ Cleaned up a bit and tweaked to actually work. - Linus ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Clean up reflog unreachability pruning decisionLinus Torvalds2009-04-011-6/+26
| | | | | | | | | | | This clarifies the pruning rules for unreachable commits by having a separate helpder function for the unreachability decision. It's preparation for actual bigger changes to come to speed up the decision when the reachability calculations become a bottleneck. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'ar/maint-mksnpath' into ar/mksnpathJunio C Hamano2008-10-301-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | * ar/maint-mksnpath: Use git_pathdup instead of xstrdup(git_path(...)) git_pathdup: returns xstrdup-ed copy of the formatted path Fix potentially dangerous use of git_path in ref.c Add git_snpath: a .git path formatting routine with output buffer Conflicts: builtin-revert.c refs.c rerere.c
| * Use git_pathdup instead of xstrdup(git_path(...))Alex Riesen2008-10-301-2/+2
| | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | builtin-reflog: Allow reflog expire to name partial refPieter de Bie2008-08-171-4/+4
|/ | | | | | | | This allows you to specify 'git reflog expire master' without needing to give the full refname like 'git reflog expire refs/heads/master' Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'maint'Junio C Hamano2008-08-111-2/+2
|\ | | | | | | | | | | | | | | | | | | | | * maint: Documentation: fix invalid reference to 'mybranch' in user manual Fix deleting reflog entries from HEAD reflog reflog test: add more tests for 'reflog delete' Documentation: rev-list-options: Fix -g paragraph formatting Conflicts: Documentation/user-manual.txt
| * Fix deleting reflog entries from HEAD reflogJunio C Hamano2008-08-101-2/+2
| | | | | | | | | | | | | | | | dwim_ref() used to resolve HEAD symbolic ref to its target (i.e. current branch). This incorrectly removed the reflog entry from the current branch when 'git reflog delete HEAD@{1}' was asked for. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Make usage strings dash-lessStephan Beyer2008-07-131-3/+3
|/ | | | | | | | | | | | | | | When you misuse a git command, you are shown the usage string. But this is currently shown in the dashed form. So if you just copy what you see, it will not work, when the dashed form is no longer supported. This patch makes git commands show the dash-less version. For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh generates a dash-less usage string now. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make default expiration period of reflog used for stash infiniteJunio C Hamano2008-06-281-0/+11
| | | | | | | | | | | This makes the default expiration period for the reflog that implements stash infinite. The original behaviour to autoexpire old stashes can be restored by using the gc.refs/stash.{reflogexpire,reflogexpireunreachable} configration variables introduced by the previous commit. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Per-ref reflog expiry configurationJunio C Hamano2008-06-281-19/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | In addition to gc.reflogexpireunreachable and gc.reflogexpire, this lets you set gc.<pattern>.reflogexpireunreachable and gc.<pattern>.reflogexpire variables. When "git reflog expire" expires reflog entry for $ref, the expiry timers are taken from the first <pattern> that matches $ref (and if there isn't the global default value is used). For example, you could: [gc "refs/stash"] reflogexpire = never reflogexpireunreachable = never [gc "refs/remotes/*"] reflogexpire = 7 days reflogexpireunreachable = 3 days [gc] reflogexpire = 90 days reflogexpireunreachable = 30 days Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make git reflog expire honour core.sharedRepository.Pierre Habouzit2008-06-151-0/+2
| | | | | Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Provide git_config with a callback-data parameterJohannes Schindelin2008-05-141-3/+3
| | | | | | | | | | | | git_config() only had a function parameter, but no callback data parameter. This assumes that all callback functions only modify global variables. With this patch, every callback gets a void * parameter, and it is hoped that this will help the libification effort. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-reflog: add option --updateref to write the last reflog sha1 into the refBrandon Casey2008-02-221-1/+16
| | | | | | | | | | | | Certain sanity checks on the reflog assume that the sha1 of the top reflog entry will be equal to the sha1 stored in the ref. When reflog entries are deleted, this assumption may not hold. This patch adds a new option to git-reflog which causes the subcommands "expire" and "delete" to update the ref with the sha1 of the top-most reflog entry. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-reflog: add option --rewrite to update reflog entries while expiringBrandon Casey2008-02-221-1/+11
| | | | | | | | | | | | | | Certain sanity checks on the reflog assume that each entry will contain a reference to the previous entry. i.e. that the "old" sha1 field of a reflog entry will be equal to the "new" sha1 field of the previous entry. When reflog entries are deleted, this assumption may not hold. This patch adds a new option to git-reflog which causes the subcommands "expire" and "delete" to rewrite the "old" sha1 field of each reflog entry so that it points to the previous reflog entry. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* reflog-delete: parse standard reflog optionsBrandon Casey2008-02-221-3/+21
| | | | | | | | Add support for some standard reflog options such as --dry-run and --verbose to the reflog delete subcommand. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'bc/reflog-fix' into js/reflog-deleteJunio C Hamano2008-02-221-9/+52
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bc/reflog-fix: (1490 commits) builtin-reflog.c: don't install new reflog on write failure hash: fix lookup_hash semantics gitweb: Better chopping in commit search results builtin-tag.c: remove cruft git-merge-index documentation: clarify synopsis send-email: fix In-Reply-To regression git-reset --hard and git-read-tree --reset: fix read_cache_unmerged() Teach git-grep --name-only as synonym for -l diff: fix java funcname pattern for solaris t3404: use configured shell instead of /bin/sh git_config_*: don't assume we are parsing a config file prefix_path: use is_absolute_path() instead of *orig == '/' git-clean: handle errors if removing files fails Clarified the meaning of git-add -u in the documentation git-clone.sh: properly configure remote even if remote's head is dangling git.el: Set process-environment instead of invoking env Documentation/git-stash: document options for git stash list send-email: squelch warning due to comparing undefined $_ to "" cvsexportcommit: be graceful when "cvs status" reorders the arguments Rename git-core rpm to just git and rename the meta-pacakge to git-all. ... Conflicts: Documentation/git-reflog.txt t/t1410-reflog.sh
| * builtin-reflog.c: don't install new reflog on write failureBrandon Casey2008-02-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | When expiring reflog entries, a new temporary log is written which contains only the entries to retain. After it is written, it is renamed to replace the existing reflog. Currently, we check that writing of the new log is successful and print a message on failure, but the original reflog is still replaced with the new reflog even on failure. This patch causes the original reflog to be retained if we fail when writing the new reflog. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * builtin-reflog.c: guard config parser from value=NULLJunio C Hamano2008-02-111-5/+11
| | | | | | | | | | | | | | gc.reflogexpire and gc.reflogexpireunreachable configuration expect a string value suitable for calling approxidate() with. Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * reflog-expire: Avoid creating new files in a directory inside readdir(3) loopJunio C Hamano2008-01-291-2/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "git reflog expire --all" opened a directory in $GIT_DIR/logs/, read reflog files in there readdir(3), and rewrote the file by creating a new file and renaming it back inside the loop. This code structure can cause the newly created file to be returned by subsequent call to readdir(3), and fall into an infinite loop in the worst case. This separates the processing to two phase. Running for_each_reflog() to find out and collect all refs, and then iterate over them, calling expire_reflog(). This way, the program would behave exactly the same way as if all the refs were given by the user from the command line. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | builtin-reflog.c: fix typo that accesses an unset variableBrandon Casey2008-01-041-1/+1
| | | | | | | | | | Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Teach "git reflog" a subcommand to delete single entriesJohannes Schindelin2007-10-171-0/+59
|/ | | | | | | | | | | | | | This commit implements the "delete" subcommand: git reflog delete master@{2} will delete the second reflog entry of the "master" branch. With this, it should be easy to implement "git stash pop" everybody seems to want these days. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* git-update-ref: add --no-deref option for overwriting/detaching refSven Verdoolaege2007-05-101-1/+1
| | | | | | | | git-checkout is also adapted to make use of this new option instead of the handcrafted command sequence. Signed-off-by: Sven Verdoolaege <skimo@kotnet.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Initialize tree descriptors with a helper function rather than by hand.Linus Torvalds2007-03-211-5/+5
| | | | | | | | | | | | | This removes slightly more lines than it adds, but the real reason for doing this is that future optimizations will require more setup of the tree descriptor, and so we want to do it in one place. Also renamed the "desc.buf" field to "desc.buffer" just to trigger compiler errors for old-style manual initializations, making sure I didn't miss anything. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* convert object type handling from a string to a numberNicolas Pitre2007-02-271-2/+2
| | | | | | | | | | | | | | | We currently have two parallel notation for dealing with object types in the code: a string and a numerical value. One of them is obviously redundent, and the most used one requires more stack space and a bunch of strcmp() all over the place. This is an initial step for the removal of the version using a char array found in object reading code paths. The patch is unfortunately large but there is no sane way to split it in smaller parts without breaking the system. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Mechanical conversion to use prefixcmp()Junio C Hamano2007-02-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mechanically converts strncmp() to use prefixcmp(), but only when the parameters match specific patterns, so that they can be verified easily. Leftover from this will be fixed in a separate step, including idiotic conversions like if (!strncmp("foo", arg, 3)) => if (!(-prefixcmp(arg, "foo"))) This was done by using this script in px.perl #!/usr/bin/perl -i.bak -p if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) { s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|; } if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) { s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|; } and running: $ git grep -l strncmp -- '*.c' | xargs perl px.perl Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'jc/merge-base' (early part)Junio C Hamano2007-02-131-2/+2
|\ | | | | | | | | This contains an evil merge to fast-import, in order to resolve in_merge_bases() update.
| * Allow in_merge_bases() to take more than one reference commits.Junio C Hamano2007-01-091-2/+2
| | | | | | | | | | | | | | | | | | The internal function in_merge_bases(A, B) is used to make sure that commit A is an ancestor of commit B. This changes the signature of it to take an array of B's and updates its current callers. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git reflog showLinus Torvalds2007-02-081-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | scan reflogs independently from refsNicolas Pitre2007-02-031-5/+2
| | | | | | | | | | | | | | | | | | Currently, the search for all reflogs depends on the existence of corresponding refs under the .git/refs/ directory. Let's scan the .git/logs/ directory directly instead. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | make reflog filename independent from struct ref_lockNicolas Pitre2007-01-281-4/+6
| | | | | | | | | | | | | | | | | | | | This allows for ref_log_write() to be used in a more flexible way, and is needed for future changes. This is only code reorg with no behavior change. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | reflog gc: a tag that does not point at a commit is not a crime.Junio C Hamano2007-01-221-3/+0
| | | | | | | | | | | | | | | | Although unusual, tags can point at any object. Warning only once is fine, but warning every time about the same tag gets annoying. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | git reflog expire: document --stale-fix option.Junio C Hamano2007-01-151-1/+1
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* | reflog-expire: brown paper bag fix.Junio C Hamano2007-01-111-6/+12
| | | | | | | | | | | | | | When --stale-fix is not passed, the code did not initialize the two commit objects properly. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Sanitize for_each_reflog_ent()Johannes Schindelin2007-01-091-14/+12
|/ | | | | | | | | | | | | | It used to ignore the return value of the helper function; now, it expects it to return 0, and stops iteration upon non-zero return values; this value is then passed on as the return value of for_each_reflog_ent(). Further, it makes no sense to force the parsing upon the helper functions; for_each_reflog_ent() now calls the helper function with old and new sha1, the email, the timestamp & timezone, and the message. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* reflog --fix-stale: do not check the same trees and commits repeatedly.Junio C Hamano2007-01-061-23/+54
| | | | | | | | Since we use the reachability tracking machinery now, we should keep the already checked trees and commits whose completeness is known, to avoid checking the same thing over and over again. Signed-off-by: Junio C Hamano <junkio@cox.net>
* reflog expire --fix-staleJunio C Hamano2007-01-061-21/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The logic in an earlier round to detect reflog entries that point at a broken commit was not sufficient. Just like we do not trust presense of a commit during pack transfer (we trust only our refs), we should not trust a commit's presense, even if the tree of that commit is complete. A repository that had reflog enabled on some of the refs that was rewound and then run git-repack or git-prune from older versions of git can have reflog entries that point at a commit that still exist but lack commits (or trees and blobs needed for that commit) between it and some commit that is reachable from one of the refs. This revamps the logic -- the definition of "broken commit" becomes: a commit that is not reachable from any of the refs and there is a missing object among the commit, tree, or blob objects reachable from it that is not reachable from any of the refs. Entries in the reflog that refer to such a commit are expired. Since this computation involves traversing all the reachable objects, i.e. it has the same cost as 'git prune', it is enabled only when a new option --fix-stale. Fortunately, once this is run, we should not have to ever worry about missing objects, because the current prune and pack-objects know about reflogs and protect objects referred by them. Unfortunately, this will be absolutely necessary to help people migrate to the newer prune and repack. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-reflog: gc.* configuration and documentation.Junio C Hamano2006-12-271-2/+23
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* reflog expire: do not punt on tags that point at non commits.Junio C Hamano2006-12-221-5/+5
| | | | | | | | It is unusual for a tag to point at a non-commit, and it is also unusual for a tag to have reflog, but that is not an error and we should still prune its reflog entries just as other refs. Signed-off-by: Junio C Hamano <junkio@cox.net>
* reflog expire: prune commits that are not incompleteJunio C Hamano2006-12-221-3/+40
| | | | | | | | | | Older fsck-objects and prune did not protect commits in reflog entries, and it is quite possible that a commit still exists in the repository (because it was in a pack, or something) while some of its trees and blobs are long gone. Make sure the commit and its associated tree is complete and expire incomplete ones. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git reflog expireJunio C Hamano2006-12-201-0/+175
This prepares a place to collect reflog management subcommands, and implements "expire" action. $ git reflog expire --dry-run \ --expire=4.weeks \ --expire-unreachable=1.week \ refs/heads/master The expiration uses two timestamps: --expire and --expire-unreachable. Entries older than expire time (defaults to 90 days), and entries older than expire-unreachable time (defaults to 30 days) and records a commit that has been rewound and made unreachable from the current tip of the ref are removed from the reflog. The parameter handling is still rough, but I think the core logic for expiration is already sound. Signed-off-by: Junio C Hamano <junkio@cox.net>