Re: The different EOL behavior between libgit2-based software and official Git

2014-06-19 Thread Torsten Bögershausen
Hm, I feeled puzzled here. Even if I wouldn't recommend to use core.autocrlf, and prefer to use .gitattributes, the CRLF conversion should work under Git, but it doensn't seem to do so. Clone this repo: origin https://github.com/YueLinHo/TestAutoCrlf.git Try to see if LF or CRLF can be converted

Re: Our merge bases sometimes suck

2014-06-19 Thread Junio C Hamano
Michael Haggerty writes: > It just looks asymmetric, but actually it is symmetric, which was kindof > surprising when I realized it > > Since "|branch ∧ master|" is the same for all candidates, minimizing N > is the same as maximizing |candidate|, which is the same as > > git rev-list --c

Re: [PATCH 10/16] fast-import: use skip_prefix for parsing input

2014-06-19 Thread Jeff King
On Thu, Jun 19, 2014 at 11:19:09PM -0400, Eric Sunshine wrote: > > - if (starts_with(command_buf.buf, "M ")) > > - file_change_m(b); > > - else if (starts_with(command_buf.buf, "D ")) > > - file_change_d(b); > > -

Re: [PATCH 14/16] fetch-pack: refactor parsing in get_ack

2014-06-19 Thread Eric Sunshine
On Wed, Jun 18, 2014 at 3:56 PM, Jeff King wrote: > There are several uses of the magic number "line+45" when > parsing ACK lines from the server, and it's rather unclear > why 45 is the correct number. We can make this more clear by > keeping a running pointer as we parse, using skip_prefix to >

Re: [PATCH 10/16] fast-import: use skip_prefix for parsing input

2014-06-19 Thread Eric Sunshine
On Wed, Jun 18, 2014 at 3:49 PM, Jeff King wrote: > Fast-import does a lot of parsing of commands and > dispatching to sub-functions. For example, given "option > foo", we might recognize "option " using starts_with, and > then hand it off to parse_option() to do the rest. > > However, we do not l

Re: [PATCH 04/16] refactor skip_prefix to return a boolean

2014-06-19 Thread Jeff King
On Thu, Jun 19, 2014 at 10:30:36PM -0400, Eric Sunshine wrote: > > diff --git a/git-compat-util.h b/git-compat-util.h > > index 556c839..1187e1a 100644 > > --- a/git-compat-util.h > > +++ b/git-compat-util.h > > @@ -350,8 +350,9 @@ extern int starts_with(const char *str, const char > > *prefix);

Re: [PATCH 04/16] refactor skip_prefix to return a boolean

2014-06-19 Thread Eric Sunshine
On Thu, Jun 19, 2014 at 10:08 PM, Jeff King wrote: > On Thu, Jun 19, 2014 at 09:59:39PM -0400, Eric Sunshine wrote: > >> > diff --git a/git-compat-util.h b/git-compat-util.h >> > index b6f03b3..556c839 100644 >> > --- a/git-compat-util.h >> > +++ b/git-compat-util.h >> > @@ -349,13 +349,31 @@ exte

Re: Should branches be objects?

2014-06-19 Thread Jeff King
On Thu, Jun 19, 2014 at 06:01:47PM -0700, Jonathan Nieder wrote: > > Speaking of which: are there any power failure corruption cases left > > in git? How is this tested? > > What kind of power failure corruption are you talking about? Git > usually updates files by writing a completely new file

Re: [PATCH 04/16] refactor skip_prefix to return a boolean

2014-06-19 Thread Jeff King
On Thu, Jun 19, 2014 at 09:59:39PM -0400, Eric Sunshine wrote: > > diff --git a/git-compat-util.h b/git-compat-util.h > > index b6f03b3..556c839 100644 > > --- a/git-compat-util.h > > +++ b/git-compat-util.h > > @@ -349,13 +349,31 @@ extern void set_die_is_recursing_routine(int > > (*routine)(voi

[PATCH v5 2/2] cleanup duplicate name_compare() functions

2014-06-19 Thread Jeremiah Mahler
We often represent our strings as a counted string, i.e. a pair of the pointer to the beginning of the string and its length, and the string may not be NUL terminated to that length. To compare a pair of such counted strings, unpack-trees.c and read-cache.c implement their own name_compare() funct

[PATCH v5 0/2] cleanup duplicate name_compare() functions

2014-06-19 Thread Jeremiah Mahler
Version 5 of the patch series to cleanup the duplicate name_compare() functions. - name-hash.c had a call to cache_name_compare() but it required that the lengths were equal. Since cache_name_compare() is equivalent to memcmp() when the lengths are equal, replace it with memcmp(). T

[PATCH v5 1/2] name-hash.c: replace cache_name_compare() with memcmp()

2014-06-19 Thread Jeremiah Mahler
When cache_name_compare() is used on counted strings of the same length, it is equivalent to a memcmp(). Since the one use of cache_name_compare() in name-hash.c requires that the lengths are equal, just replace it with memcmp(). Signed-off-by: Jeremiah Mahler --- name-hash.c | 2 +- 1 file cha

Re: [PATCH 04/16] refactor skip_prefix to return a boolean

2014-06-19 Thread Eric Sunshine
On Wed, Jun 18, 2014 at 3:44 PM, Jeff King wrote: > The skip_prefix function returns a pointer to the content > past the prefix, or NULL if the prefix was not found. While > this is nice and simple, in practice it makes it hard to use > for two reasons: > > 1. When you want to conditionally skip

Re: [PATCH v4] cleanup duplicate name_compare() functions

2014-06-19 Thread Jeremiah Mahler
Junio, On Thu, Jun 19, 2014 at 11:29:21AM -0700, Junio C Hamano wrote: > On Thu, Jun 19, 2014 at 11:03 AM, Junio C Hamano wrote: > > > > You chose to use the one that loses the information by unifying > > these two into the variant that only returns -1/0/+1. We know that > > it does not matter f

Re: Conventions on struct copying?

2014-06-19 Thread brian m. carlson
On Thu, Jun 19, 2014 at 01:22:44PM -0400, Jason Pyeron wrote: > > -Original Message- > > From: Junio C Hamano > > Sent: Thursday, June 19, 2014 13:11 > > > > "brian m. carlson" writes: > > > > > I don't know of any place we explicitly copy structs like > > > this,... > > > > which shoul

Re: Should branches be objects?

2014-06-19 Thread Jonathan Nieder
Nico Williams wrote: > a) reflogs include information about what's done to the workspace > (checkout...) that's not relevant to any branch, Nope, reflogs just record changes to refs and information about why they happened. > b) reflogs aren't objects, which ISTM has caused transactional issued >

Re: Should branches be objects?

2014-06-19 Thread Nico Williams
Another thing is that branches as objects could store a lot more information, like: - the merge-base and HEAD for a rebase (and the --onto) - the interactive rebase plan! (and diffs to what would have been the non-interactive plan) - the would-be no-op non-interactive rebase plan post rebase

Re: Should branches be objects?

2014-06-19 Thread Nico Williams
On Thu, Jun 19, 2014 at 6:46 PM, Jonathan Nieder wrote: > Nico Williams wrote: > >> - one could see the history of branches, including > > Interesting. 'git log -g' is good for getting that information > locally, but the protocol doesn't have a way to get it from a remote > server so you have to

Re: Should branches be objects?

2014-06-19 Thread Jonathan Nieder
Hi, Nico Williams wrote: > - one could see the history of branches, including Interesting. 'git log -g' is good for getting that information locally, but the protocol doesn't have a way to get it from a remote server so you have to ssh in. Ronnie (cc-ed) and I were talking recently about whet

Re: [PATCH 17/16] http-push: refactor parsing of remote object names

2014-06-19 Thread Jeff King
On Thu, Jun 19, 2014 at 05:58:10PM -0400, Jeff King wrote: > It's still a little more magical than I would like, but I think this is > the best we can do while still building on get_sha1_hex. Parsing it > left-to-right would be better, but we would essentially end up > reimplementing get_sha1_hex.

[PATCH 17/16] http-push: refactor parsing of remote object names

2014-06-19 Thread Jeff King
We get loose object names like "objects/??/..." from the remote side, and need to convert them to their hex representation. The code to do so is rather hard to follow, as it uses some calculated lengths whose origins are hard to understand and verify (e.g., the path must be exactly 49 characters l

Re: Surprising 'git-describe --all --match' behavior.

2014-06-19 Thread Junio C Hamano
Sergei Organov writes: > Junio C Hamano writes: > >> Sergei Organov writes: >> >>> Will something break if it won't helpfully prepend refs/tags/ once >>> --all is given? >> >> "describe --all --match 'v*'" will no longer match a tag v1.2.3, and >> forces the users to say "describe --match 'refs

Should branches be objects?

2014-06-19 Thread Nico Williams
[I'm a list newbie here, but a git power user.] If branches were objects... - one could see the history of branches, including - how commits were grouped when pushed/pulled (push 5 commits, and the branch object will record that its head moved by those five commits at once) - rebase history

[PATCH v2 10/10] unique_path: fix unlikely heap overflow

2014-06-19 Thread Jeff King
When merge-recursive creates a unique filename, it uses a template like: path~branch_%d where the final "_%d" is filled by an incrementing counter until we find a unique name. We allocate 8 characters for the counter, but there is no logic to limit the size of the integer. Of course, this is e

[PATCH v2 09/10] walker_fetch: fix minor memory leak

2014-06-19 Thread Jeff King
We sometimes allocate "msg" on the heap, but will fail to free it if we hit the failure code path. We can instead keep a separate variable that is safe to be freed no matter how we get to the failure code path. While we're here, we can also do two readability improvements: 1. Use xstrfmt instea

[PATCH v2 08/10] merge: use argv_array when spawning merge strategy

2014-06-19 Thread Jeff King
This is shorter, and avoids a rather complicated set of allocation and free steps. Signed-off-by: Jeff King --- merge.c | 42 +- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/merge.c b/merge.c index 70f1000..1fa6e52 100644 --- a/merge.c +

[PATCH v2 07/10] sequencer: use argv_array_pushf

2014-06-19 Thread Jeff King
This avoids a manual allocation calculation, and is shorter to boot. Signed-off-by: Jeff King --- sequencer.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sequencer.c b/sequencer.c index 0a80c58..2fea824 100644 --- a/sequencer.c +++ b/sequencer.c @@ -396,18 +396,1

[PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

2014-06-19 Thread Jeff King
This is shorter, harder to get wrong, and more clearly captures the intent. Signed-off-by: Jeff King --- I wondered if there was a reason to avoid this (because we are in setup_git_env, which can potentially be called by git_pathdup). But the git_graft_file initialization below already uses it, a

[PATCH v2 05/10] use xstrfmt to replace xmalloc + strcpy/strcat

2014-06-19 Thread Jeff King
It's easy to get manual allocation calculations wrong, and the use of strcpy/strcat raise red flags for people looking for buffer overflows (though in this case each site was fine). It's also shorter to use xstrfmt, and the printf-format tends to be easier for a reader to see what the final string

[PATCH v2 04/10] use xstrfmt to replace xmalloc + sprintf

2014-06-19 Thread Jeff King
This is one line shorter, and makes sure the length in the malloc and sprintf steps match. These conversions are very straightforward; we can drop the malloc entirely, and replace the sprintf with xstrfmt. Signed-off-by: Jeff King --- Just a note on one thing I would look for as a reviewer: I

[PATCH v2 02/10] use xstrfmt in favor of manual size calculations

2014-06-19 Thread Jeff King
In many parts of the code, we do an ugly and error-prone malloc like: const char *fmt = "something %s"; buf = xmalloc(strlen(foo) + 10 + 1); sprintf(buf, fmt, foo); This makes the code brittle, and if we ever get the allocation wrong, is a potential heap overflow. Let's instead favor xstrfm

[PATCH v2 03/10] use xstrdup instead of xmalloc + strcpy

2014-06-19 Thread Jeff King
This is one line shorter, and makes sure the length in the malloc and copy steps match. Signed-off-by: Jeff King --- builtin/receive-pack.c | 5 + http-push.c| 6 ++ http-walker.c | 3 +-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/builtin/receiv

[PATCH v2 01/10] strbuf: add xstrfmt helper

2014-06-19 Thread Jeff King
You can use a strbuf to build up a string from parts, and then detach it. In the general case, you might use multiple strbuf_add* functions to do the building. However, in many cases, a single strbuf_addf is sufficient, and we end up with: struct strbuf buf = STRBUF_INIT; ... strbuf_addf(&bu

[PATCH v2] dropping manual malloc calculations

2014-06-19 Thread Jeff King
On Thu, Jun 19, 2014 at 09:49:41AM -0700, Junio C Hamano wrote: > If we twist the logic behind the 'mkpathdup' name a little bit, > perhaps we can call it sprintf_dup or something. That is, "sprintf > wants a fixed preallocated piece of memory to print into, and we > relieve the callers of having

Re: [PATCH v4] cleanup duplicate name_compare() functions

2014-06-19 Thread Jeremiah Mahler
Junio, On Thu, Jun 19, 2014 at 11:03:03AM -0700, Junio C Hamano wrote: > Jeremiah Mahler writes: > > > Both unpack-trees.c and read-cache.c have their own name_compare() > > function, which are identical. And read-cache.c has a > > cache_name_compare() function which is nearly identical to > >

Re: What's cooking in git.git (Jun 2014, #04; Tue, 17)

2014-06-19 Thread Junio C Hamano
Duy Nguyen writes: > On Thu, Jun 19, 2014 at 12:25 AM, Junio C Hamano wrote: >> [Stalled] >> * nd/multiple-work-trees (2014-03-25) 28 commits >> - count-objects: report unused files in $GIT_DIR/repos/... >> - gc: support prune --repos >> - gc: style change -- no SP before closing bracket >>

[PATCH v2 14/14] revert: add t3513 for submodule updates

2014-06-19 Thread Jens Lehmann
Test that the revert command updates the work tree as expected (for submodule changes which don't result in conflicts). Add a helper function to first revert the checked out target commit to make the last revert produce the to-be-tested work tree. Set the KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMI

[PATCH v2 09/14] rebase: add t3426 for submodule updates

2014-06-19 Thread Jens Lehmann
Test that the rebase command updates the work tree as expected for changes which don't result in conflicts. To make that work add two helper functions that add a commit only touching files and then revert it. This allows to rebase the target commit over these two and to compare the result. Set KNO

[PATCH v2 13/14] stash: add t3906 for submodule updates

2014-06-19 Thread Jens Lehmann
Test that the stash apply command updates the work tree as expected for changes which don't result in conflicts. To make that work add a helper function that uses read-tree to apply the changes of the target commit to the work tree, then stashes these changes and at last applies that stash. Implem

[PATCH v2 02/14] submodules: Add the lib-submodule-update.sh test library

2014-06-19 Thread Jens Lehmann
Add this test library to simplify covering all combinations of submodule update scenarios without having to add those to a test of each work tree manipulating command over and over again. The functions test_submodule_switch() and test_submodule_forced_switch() are intended to be called from a test

[PATCH v2 01/14] test-lib: add test_dir_is_empty()

2014-06-19 Thread Jens Lehmann
For the upcoming submodule test framework we often need to assert that an empty directory exists in the work tree. Add the test_dir_is_empty() function which asserts that the given argument is an empty directory. Signed-off-by: Jens Lehmann --- Changes to v1: *) Added "-n" to test expression (

[PATCH v2 07/14] bisect: add t6041 for submodule updates

2014-06-19 Thread Jens Lehmann
Test that the bisect command updates the work tree as expected. To make that work with the new submodule test framework a git_bisect helper function is added. This adds a commit after the one given to be switched to and makes that one the bad commit. The starting point is then given to bisect as th

Re: Surprising 'git-describe --all --match' behavior.

2014-06-19 Thread Sergei Organov
Junio C Hamano writes: > Sergei Organov writes: > >> Will something break if it won't helpfully prepend refs/tags/ once >> --all is given? > > "describe --all --match 'v*'" will no longer match a tag v1.2.3, and > forces the users to say "describe --match 'refs/tags/v*'", No, descirbe --match

Re: Surprising 'git-describe --all --match' behavior.

2014-06-19 Thread Junio C Hamano
Sergei Organov writes: > Will something break if it won't helpfully prepend refs/tags/ once > --all is given? "describe --all --match 'v*'" will no longer match a tag v1.2.3, and forces the users to say "describe --match 'refs/tags/v*'", and these users will probably see it as a new breakage, I

Re: Surprising 'git-describe --all --match' behavior.

2014-06-19 Thread Sergei Organov
Junio C Hamano writes: > Sergei Organov writes: > >> Just playing with it, got some surprises: >> >> $ git --version >> git version 1.9.3 >> >> $ git describe --all >> heads/v3.5 >> $ git describe --all --match 'v*' >> tags/v3.5.6b2-4-gab4bf78 >> $ git describe --all --match 'heads/v*' >> fatal:

Re: [PATCH v4] cleanup duplicate name_compare() functions

2014-06-19 Thread Junio C Hamano
On Thu, Jun 19, 2014 at 11:03 AM, Junio C Hamano wrote: > > You chose to use the one that loses the information by unifying > these two into the variant that only returns -1/0/+1. We know that > it does not matter for the current callers, but is it expected that > no future callers will benefit b

Re: [PATCH v4] cleanup duplicate name_compare() functions

2014-06-19 Thread Junio C Hamano
Jeremiah Mahler writes: > Both unpack-trees.c and read-cache.c have their own name_compare() > function, which are identical. And read-cache.c has a > cache_name_compare() function which is nearly identical to > name_compare() [1]. The cache_name_compare() function is not specific > to a cache,

RE: Conventions on struct copying?

2014-06-19 Thread Jason Pyeron
> -Original Message- > From: Junio C Hamano > Sent: Thursday, June 19, 2014 13:11 > > "brian m. carlson" writes: > > > I don't know of any place we explicitly copy structs like > > this,... > > which should be a reason enough. The first concrete guideline is > "just imitate the existin

Re: Surprising 'git-describe --all --match' behavior.

2014-06-19 Thread Junio C Hamano
Sergei Organov writes: > Just playing with it, got some surprises: > > $ git --version > git version 1.9.3 > > $ git describe --all > heads/v3.5 > $ git describe --all --match 'v*' > tags/v3.5.6b2-4-gab4bf78 > $ git describe --all --match 'heads/v*' > fatal: No names found, cannot describe anythi

Re: Conventions on struct copying?

2014-06-19 Thread Junio C Hamano
"brian m. carlson" writes: > I don't know of any place we explicitly copy structs like > this,... which should be a reason enough. The first concrete guideline is "just imitate the existing code". > but I don't know of any prohibition against it, either. So now you know ;-). -- To unsubscribe

Re: [PATCH 1/2] strbuf: add xstrdup_fmt helper

2014-06-19 Thread René Scharfe
Am 19.06.2014 11:05, schrieb Jeff King: On Wed, Jun 18, 2014 at 03:32:08PM -0700, Junio C Hamano wrote: str = xstrdup_fmt(fmt, some, args); --- I'm open to suggestions on the name. This really is the same thing conceptually as the GNU asprintf(), but the interface is different (that function

Re: [PATCH 1/2] strbuf: add xstrdup_fmt helper

2014-06-19 Thread Junio C Hamano
Jeff King writes: > On Wed, Jun 18, 2014 at 03:32:08PM -0700, Junio C Hamano wrote: > >> > str = xstrdup_fmt(fmt, some, args); >> > --- >> > I'm open to suggestions on the name. This really is the same thing >> > conceptually as the GNU asprintf(), but the interface is different (that >> > func

[PATCH v19 07/48] lockfile.c: make lock_file return a meaningful errno on failurei

2014-06-19 Thread Ronnie Sahlberg
Making errno when returning from lock_file() meaningful, which should fix * an existing almost-bug in lock_ref_sha1_basic where it assumes errno==ENOENT is meaningful and could waste some work on retries * an existing bug in repack_without_refs where it prints strerror(errno) and picks ad

[PATCH v19 09/48] refs.c: make sure log_ref_setup returns a meaningful errno

2014-06-19 Thread Ronnie Sahlberg
Making errno when returning from log_ref_setup() meaningful, Signed-off-by: Ronnie Sahlberg --- refs.c | 27 +++ refs.h | 4 +++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/refs.c b/refs.c index 67a0217..9ea519c 100644 --- a/refs.c +++ b/refs.c @@ -2

[PATCH v19 05/48] refs.c: add a strbuf argument to ref_transaction_commit for error logging

2014-06-19 Thread Ronnie Sahlberg
Add a strbuf argument to _commit so that we can pass an error string back to the caller. So that we can do error logging from the caller instead of from _commit. Longer term plan is to first convert all callers to use onerr==QUIET_ON_ERR and craft any log messages from the callers themselves and f

[PATCH v19 12/48] refs.c: commit_packed_refs to return a meaningful errno on failure

2014-06-19 Thread Ronnie Sahlberg
Making errno when returning from commit_packed_refs() meaningful, which should fix * a bug in "git clone" where it prints strerror(errno) based on errno, despite errno possibly being zero and potentially having been clobbered by that point * the same kind of bug in "git pack-refs" and pre

[PATCH v19 06/48] lockfile.c: add a new public function unable_to_lock_message

2014-06-19 Thread Ronnie Sahlberg
Introducing a new unable_to_lock_message helper, which has nicer semantics than unable_to_lock_error and cleans up lockfile.c a little. Signed-off-by: Ronnie Sahlberg --- cache.h| 2 ++ lockfile.c | 22 -- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/

Re: [PATCH v18 16/48] refs.c: add an err argument to delete_ref_loose

2014-06-19 Thread Ronnie Sahlberg
I have resent v19 that does 1, remove the spurios redundant errno line 2, fixes the type and 3, reorders the patch as mentioned previously in this thread. This I hope will be the final version of the series we will need. regards ronnie sahlberg On Wed, Jun 18, 2014 at 3:38 PM, Michael Haggerty

[PATCH v19 02/48] refs.c: ref_transaction_commit should not free the transaction

2014-06-19 Thread Ronnie Sahlberg
Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 1 + refs.c | 1 - refs.h | 5 ++--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 405267f..1fd7a89 100644 --- a/b

[PATCH v19 14/48] refs.c: log_ref_write should try to return meaningful errno

2014-06-19 Thread Ronnie Sahlberg
Making errno from write_ref_sha1() meaningful, which should fix * a bug in "git checkout -b" where it prints strerror(errno)  despite errno possibly being zero or clobbered * a bug in "git fetch"'s s_update_ref, which trusts the result of an  errno == ENOTDIR check to detect D/F conflicts Sign

[PATCH v19 19/48] refs.c: change ref_transaction_update() to do error checking and return status

2014-06-19 Thread Ronnie Sahlberg
Update ref_transaction_update() do some basic error checking and return non-zero on error. Update all callers to check ref_transaction_update() for error. There are currently no conditions in _update that will return error but there will be in the future. Add an err argument that will be updated on

[PATCH v19 11/48] refs.c: make remove_empty_directories always set errno to something sane

2014-06-19 Thread Ronnie Sahlberg
Making errno when returning from remove_empty_directories() more obviously meaningful, which should provide some peace of mind for people auditing lock_ref_sha1_basic. Signed-off-by: Ronnie Sahlberg --- refs.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.

[PATCH v19 17/48] update-ref: use err argument to get error from ref_transaction_commit

2014-06-19 Thread Ronnie Sahlberg
Call ref_transaction_commit with QUIET_ON_ERR and use the strbuf that is returned to print a log message if/after the transaction fails. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --

[PATCH v19 34/48] refs.c: make lock_ref_sha1 static

2014-06-19 Thread Ronnie Sahlberg
No external callers reference lock_ref_sha1 any more so lets declare it static. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- refs.h | 6 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/refs.c b/refs.c index 8b2c598..db8e0a0 100644 --- a/ref

[PATCH v19 13/48] refs.c: make resolve_ref_unsafe set errno to something meaningful on error

2014-06-19 Thread Ronnie Sahlberg
Making errno when returning from resolve_ref_unsafe() meaningful, which should fix * a bug in lock_ref_sha1_basic, where it assumes EISDIR means it failed due to a directory being in the way Signed-off-by: Ronnie Sahlberg --- cache.h | 2 +- refs.c | 19 +++ 2 files change

[PATCH v19 29/48] branch.c: use ref transaction for all ref updates

2014-06-19 Thread Ronnie Sahlberg
Change create_branch to use a ref transaction when creating the new branch. This also fixes a race condition in the old code where two concurrent create_branch could race since the lock_any_ref_for_update/write_ref_sha1 did not protect against the ref already existing. I.e. one thread could end up

[PATCH v19 01/48] refs.c: remove ref_transaction_rollback

2014-06-19 Thread Ronnie Sahlberg
We do not yet need both a rollback and a free function for transactions. Remove ref_transaction_rollback and use ref_transaction_free instead. At a later stage we may reintroduce a rollback function if we want to start adding reusable transactions and similar. Reviewed-by: Jonathan Nieder Signed

[PATCH v19 18/48] refs.c: remove the onerr argument to ref_transaction_commit

2014-06-19 Thread Ronnie Sahlberg
Since all callers now use QUIET_ON_ERR we no longer need to provide an onerr argument any more. Remove the onerr argument from the ref_transaction_commit signature. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/update-ref.c | 3 +-- refs.c | 22 +++--

[PATCH v19 24/48] tag.c: use ref transactions when doing updates

2014-06-19 Thread Ronnie Sahlberg
Change tag.c to use ref transactions for all ref updates. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/tag.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/builtin/tag.c b/builtin/tag.c index c6e8a71..c9bfc9a 100644 --- a/builtin/t

[PATCH v19 22/48] refs.c: make ref_transaction_begin take an err argument

2014-06-19 Thread Ronnie Sahlberg
Add an err argument to _begin so that on non-fatal failures in future ref backends we can report a nice error back to the caller. While _begin can currently never fail for other reasons than OOM, in which case we die() anyway, we may add other types of backends in the future. For example, a hypothe

[PATCH v19 21/48] refs.c: update ref_transaction_delete to check for error and return status

2014-06-19 Thread Ronnie Sahlberg
Change ref_transaction_delete() to do basic error checking and return non-zero of error. Update all callers to check the return for ref_transaction_delete(). There are currently no conditions in _delete that will return error but there will be in the future. Add an err argument that will be updated

[PATCH v19 36/48] refs.c: remove the update_ref_write function

2014-06-19 Thread Ronnie Sahlberg
Since we only call update_ref_write from a single place and we only call it with onerr==QUIET_ON_ERR we can just as well get rid of it and just call write_ref_sha1 directly. This changes the return status for _commit from 1 to -1 on failures when writing to the ref. Eventually we will want _commit

[PATCH v19 27/48] sequencer.c: use ref transactions for all ref updates

2014-06-19 Thread Ronnie Sahlberg
Change to use ref transactions for all updates to refs. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- sequencer.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/sequencer.c b/sequencer.c index 0a80c58..fd8acaf 100644 --- a/sequenc

[PATCH v19 26/48] commit.c: use ref transactions for updates

2014-06-19 Thread Ronnie Sahlberg
Change commit.c to use ref transactions for all ref updates. Make sure we pass a NULL pointer to ref_transaction_update if have_old is false. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/commit.c | 24 +++- 1 file changed, 11 insertions(+), 13 dele

[PATCH v19 23/48] refs.c: add transaction.status and track OPEN/CLOSED/ERROR

2014-06-19 Thread Ronnie Sahlberg
Track the status of a transaction in a new status field. Check the field for sanity, i.e. that status must be OPEN when _commit/_create/_delete or _update is called or else die(BUG:...) Signed-off-by: Ronnie Sahlberg --- refs.c | 40 +++- 1 file changed, 39 in

[PATCH v19 20/48] refs.c: change ref_transaction_create to do error checking and return status

2014-06-19 Thread Ronnie Sahlberg
Do basic error checking in ref_transaction_create() and make it return non-zero on error. Update all callers to check the result of ref_transaction_create(). There are currently no conditions in _create that will return error but there will be in the future. Add an err argument that will be updated

[PATCH v19 39/48] refs.c: make delete_ref use a transaction

2014-06-19 Thread Ronnie Sahlberg
Change delete_ref to use a ref transaction for the deletion. At the same time since we no longer have any callers of repack_without_ref we can now delete this function. Change delete_ref to return 0 on success and 1 on failure instead of the previous 0 on success either 1 or -1 on failure. Review

[PATCH v19 32/48] fast-import.c: use a ref transaction when dumping tags

2014-06-19 Thread Ronnie Sahlberg
Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- fast-import.c | 29 +++-- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/fast-import.c b/fast-import.c index cd929dc..191fc47 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1734,15 +1734,3

[PATCH v19 31/48] receive-pack.c: use a reference transaction for updating the refs

2014-06-19 Thread Ronnie Sahlberg
Wrap all the ref updates inside a transaction. Signed-off-by: Ronnie Sahlberg --- builtin/receive-pack.c | 96 +- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index c323081..b51f8ae

[PATCH v19 28/48] fast-import.c: change update_branch to use ref transactions

2014-06-19 Thread Ronnie Sahlberg
Change update_branch() to use ref transactions for updates. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- fast-import.c | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/fast-import.c b/fast-import.c index 6707a66..cd929dc 100644

[PATCH v19 08/48] refs.c: add an err argument to repack_without_refs

2014-06-19 Thread Ronnie Sahlberg
Update repack_without_refs to take an err argument and update it if there is a failure. Pass the err variable from ref_transaction_commit to this function so that callers can print a meaningful error message if _commit fails due to this function. Signed-off-by: Ronnie Sahlberg --- builtin/remote

[PATCH v19 42/48] refs.c: pass NULL as *flags to read_ref_full

2014-06-19 Thread Ronnie Sahlberg
We call read_ref_full with a pointer to flags from rename_ref but since we never actually use the returned flags we can just pass NULL here instead. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c

[PATCH v19 47/48] fetch.c: change s_update_ref to use a ref transaction

2014-06-19 Thread Ronnie Sahlberg
Change s_update_ref to use a ref transaction for the ref update. Signed-off-by: Ronnie Sahlberg --- builtin/fetch.c | 33 +++-- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index faa1233..52f1ebc 100644 --- a/builti

[PATCH v19 37/48] refs.c: remove lock_ref_sha1

2014-06-19 Thread Ronnie Sahlberg
lock_ref_sha1 was only called from one place in refc.c and only provided a check that the refname was sane before adding back the initial "refs/" part of the ref path name, the initial "refs/" that this caller had already stripped off before calling lock_ref_sha1. Reviewed-by: Jonathan Nieder Sig

[PATCH v19 33/48] walker.c: use ref transaction for ref updates

2014-06-19 Thread Ronnie Sahlberg
Switch to using ref transactions in walker_fetch(). As part of the refactoring to use ref transactions we also fix a potential memory leak where in the original code if write_ref_sha1() would fail we would end up returning from the function without free()ing the msg string. Note that this function

[PATCH v19 04/48] refs.c: allow passing NULL to ref_transaction_free

2014-06-19 Thread Ronnie Sahlberg
Allow ref_transaction_free(NULL) as a no-op. This makes ref_transaction_free easier to use and more similar to plain 'free'. In particular, it lets us rollback unconditionally as part of cleanup code after setting 'transaction = NULL' if a transaction has been committed or rolled back already. Re

[PATCH v19 41/48] refs.c: pass the ref log message to _create/delete/update instead of _commit

2014-06-19 Thread Ronnie Sahlberg
Change the reference transactions so that we pass the reflog message through to the create/delete/update function instead of the commit message. This allows for individual messages for each change in a multi ref transaction. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- branch

[PATCH v19 35/48] refs.c: remove the update_ref_lock function

2014-06-19 Thread Ronnie Sahlberg
Since we now only call update_ref_lock with onerr==QUIET_ON_ERR we no longer need this function and can replace it with just calling lock_any_ref_for_update directly. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 30 ++ 1 file changed, 6 in

[PATCH v19 15/48] refs.c: make ref_update_reject_duplicates take a strbuf argument for errors

2014-06-19 Thread Ronnie Sahlberg
Make ref_update_reject_duplicates return any error that occurs through a new strbuf argument. This means that when a transaction commit fails in this function we will now be able to pass a helpful error message back to the caller. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg ---

[PATCH v19 46/48] refs.c: propagate any errno==ENOTDIR from _commit back to the callers

2014-06-19 Thread Ronnie Sahlberg
In _commit, ENOTDIR can happen in the call to lock_ref_sha1_basic, either when we lstat the new refname and it returns ENOTDIR or if the name checking function reports that the same type of conflict happened. In both cases it means that we can not create the new ref due to a name conflict. For the

[PATCH v19 40/48] refs.c: add an err argument to delete_ref_loose

2014-06-19 Thread Ronnie Sahlberg
Add an err argument to delete_loose_ref so that we can pass a descriptive error string back to the caller. Pass the err argument from transaction commit to this function so that transaction users will have a nice error string if the transaction failed due to delete_loose_ref. Add a new function un

[PATCH v19 43/48] refs.c: move the check for valid refname to lock_ref_sha1_basic

2014-06-19 Thread Ronnie Sahlberg
Move the check for check_refname_format from lock_any_ref_for_update to lock_ref_sha1_basic. At some later stage we will get rid of lock_any_ref_for_update completely. If lock_ref_sha1_basic fails the check_refname_format test, set errno to EINVAL before returning NULL. This to guarantee that we w

[PATCH v19 38/48] refs.c: make prune_ref use a transaction to delete the ref

2014-06-19 Thread Ronnie Sahlberg
Change prune_ref to delete the ref using a ref transaction. To do this we also need to add a new flag REF_ISPRUNING that will tell the transaction that we do not want to delete this ref from the packed refs. This flag is private to refs.c and not exposed to external callers. Reviewed-by: Jonathan

[PATCH v19 30/48] refs.c: change update_ref to use a transaction

2014-06-19 Thread Ronnie Sahlberg
Change the update_ref helper function to use a ref transaction internally. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 25 + 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/refs.c b/refs.c index 8c695ba..8b2c598 100644 --- a/re

[PATCH v19 45/48] refs.c: pass a skip list to name_conflict_fn

2014-06-19 Thread Ronnie Sahlberg
Allow passing a list of refs to skip checking to name_conflict_fn. There are some conditions where we want to allow a temporary conflict and skip checking those refs. For example if we have a transaction that 1, guarantees that m is a packed refs and there is no loose ref for m 2, the transaction w

[PATCH v19 10/48] refs.c: verify_lock should set errno to something meaningful

2014-06-19 Thread Ronnie Sahlberg
Making errno when returning from verify_lock() meaningful, which should almost but not completely fix * a bug in "git fetch"'s s_update_ref, which trusts the result of an errno == ENOTDIR check to detect D/F conflicts ENOTDIR makes sense as a sign that a file was in the way of a directory we

[PATCH v19 16/48] refs.c: make update_ref_write update a strbuf on failure

2014-06-19 Thread Ronnie Sahlberg
Change update_ref_write to also update an error strbuf on failure. This makes the error available to ref_transaction_commit callers if the transaction failed due to update_ref_sha1/write_ref_sha1 failures. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 9 ++--- 1 f

[PATCH v19 44/48] refs.c: call lock_ref_sha1_basic directly from commit

2014-06-19 Thread Ronnie Sahlberg
Skip using the lock_any_ref_for_update wrapper and call lock_ref_sha1_basic directly from the commit function. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- refs.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/refs.c b/refs.c index 5a7fb34..2

[PATCH v19 48/48] refs.c: make write_ref_sha1 static

2014-06-19 Thread Ronnie Sahlberg
No external users call write_ref_sha1 any more so lets declare it static. Signed-off-by: Ronnie Sahlberg --- refs.c | 10 -- refs.h | 3 --- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/refs.c b/refs.c index f4234b9..1529a26 100644 --- a/refs.c +++ b/refs.c @@ -2665,6

[PATCH v19 25/48] replace.c: use the ref transaction functions for updates

2014-06-19 Thread Ronnie Sahlberg
Update replace.c to use ref transactions for updates. Reviewed-by: Jonathan Nieder Signed-off-by: Ronnie Sahlberg --- builtin/replace.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/builtin/replace.c b/builtin/replace.c index 1bb491d..054f5ef 100644 ---

  1   2   >