1
0
mirror of https://github.com/git/git.git synced 2024-10-01 01:21:24 +02:00
Commit Graph

23 Commits

Author SHA1 Message Date
Shawn Pearce
9befac470b Replace uses of strdup with xstrdup.
Like xmalloc and xrealloc xstrdup dies with a useful message if
the native strdup() implementation returns NULL rather than a
valid pointer.

I just tried to use xstrdup in new code and found it to be missing.
However I expected it to be present as xmalloc and xrealloc are
already commonly used throughout the code.

[jc: removed the part that deals with last_XXX, which I am
 finding more and more dubious these days.]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-02 03:24:37 -07:00
Jonas Fonseca
2d7320d0b0 Use xmalloc instead of malloc
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-31 16:24:39 -07:00
Junio C Hamano
87cb004e42 hashcpy/hashcmp remaining bits.
This fixes up merge-recursive.c for hashcpy/hashcmp changes.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-23 14:31:20 -07:00
Shawn Pearce
8da7149394 Convert memcpy(a,b,20) to hashcpy(a,b).
This abstracts away the size of the hash values when copying them
from memory location to memory location, much as the introduction
of hashcmp abstracted away hash value comparsion.

A few call sites were using char* rather than unsigned char* so
I added the cast rather than open hashcpy to be void*.  This is a
reasonable tradeoff as most call sites already use unsigned char*
and the existing hashcmp is also declared to be unsigned char*.

[jc: this is a follow-up patch for merge-recursive.c which is
 not in "master" yet.  The original was sent-in for "next" so
 I splitted it out. ]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-23 14:27:00 -07:00
Junio C Hamano
eed94a570e Merge branch 'master' into js/c-merge-recursive
Adjust to hold_lock_file_for_update() change on the master.
2006-08-12 18:35:14 -07:00
Johannes Schindelin
984b65707e merge-recur: do not die unnecessarily
When the cache is dirty, and we switch the index file from temporary
to final, we want to discard the cache without complaint.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-09 14:57:27 -07:00
Johannes Schindelin
8918b0c9c2 merge-recur: try to merge older merge bases first
It seems to be the only sane way to do it: when a two-head merge is
done, and the merge-base and one of the two branches agree, the
merge assumes that the other branch has something new.

If we start creating virtual commits from newer merge-bases, and go
back to older merge-bases, and then merge with newer commits again,
chances are that a patch is lost, _because_ the merge-base and the
head agree on it. Unlikely, yes, but it happened to me.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-09 14:57:22 -07:00
Johannes Schindelin
934d9a2407 merge-recur: if there is no common ancestor, fake empty one
This fixes the coolest merge ever.

[jc: with two "Oops that's not it" fixes from Johannes and Alex,
 and an obvious type mismatch fix.]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-09 14:54:00 -07:00
Johannes Schindelin
c1964a006f merge-recur: do not setenv("GIT_INDEX_FILE")
Since there are no external calls left in merge-recur, we do not need
to set the environment variable GIT_INDEX_FILE all the time.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-09 14:49:26 -07:00
Johannes Schindelin
5b982f84ee merge-recur: do not call git-write-tree
Since merge-recur is in C, and uses libgit, it can call the relevant
functions directly, without writing the index file.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-09 14:46:47 -07:00
Johannes Schindelin
3d234d0afa merge-recursive: fix rename handling
To handle renames properly, we iterate through all file names of both
heads, the current one, and the one to be merged.

Only that there was a bug, where it was checked if the file name was present
in both heads, but the result of the check was never used. Instead, the
merge proceeded as if both heads contained that file.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-04 11:30:35 -07:00
Johannes Schindelin
c1f3089e4b merge-recur: virtual commits shall never be parsed
It would not make sense to parse a virtual commit, therefore set the
"parsed" flag to 1.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-31 15:41:12 -07:00
Johannes Schindelin
7a85b848ad merge-recur: use the unpack_trees() interface instead of exec()ing read-tree
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-30 23:55:49 -07:00
Johannes Schindelin
f59aac47f3 merge-recur: fix thinko in unique_path()
This could result in a nasty infinite loop, or in bogus names (it used
the strlen() of the newly allocated buffer instead of the original
buffer).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-30 14:23:00 -07:00
Johannes Schindelin
3058e9339f merge-recur: Explain why sha_eq() and struct stage_data cannot go
There were two TODOs to remove sha_eq() and to convert users of
struct stage_data to active_cache users, but this is not possible.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-27 19:39:15 -07:00
Johannes Schindelin
c1d20846f4 merge-recur: Cleanup last mixedCase variables...
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-27 19:39:15 -07:00
Johannes Schindelin
7b3f5daabc merge-recur: Fix compiler warning with -pedantic
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-27 19:39:15 -07:00
Johannes Schindelin
5d3afe05d9 merge-recur: Remove dead code
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-27 19:39:15 -07:00
Johannes Schindelin
bd669986f7 merge-recur: Get rid of debug code
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-27 19:39:15 -07:00
Johannes Schindelin
5a75361340 merge-recur: Convert variable names to lower_case
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-27 19:39:15 -07:00
Johannes Schindelin
3af244caa8 Cumulative update of merge-recursive in C
This contains mainly three sorts of fixes:

- get rid of small wrapper functions
- reuse the diff_filespec structure when sha1, mode & path are needed
- Junio's pedantic updates

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-27 19:39:15 -07:00
Junio C Hamano
bf6d324e73 Merge branch 'lt/unitype' into js/c-merge-recursive
* lt/unitype:
  builtin-prune.c: forgot TYPE => OBJ changes.
  Remove TYPE_* constant macros and use object_type enums consistently.
2006-07-13 23:38:40 -07:00
Johannes Schindelin
6d297f8137 Status update on merge-recursive in C
This is just an update for people being interested. Alex and me were
busy with that project for a few days now. While it has progressed nicely,
there are quite a couple TODOs in merge-recursive.c, just search for "TODO".

For impatient people: yes, it passes all the tests, and yes, according
to the evil test Alex did, it is faster than the Python script.

But no, it is not yet finished. Biggest points are:

- there are still three external calls
- in the end, it should not be necessary to write the index more than once
  (just before exiting)
- a lot of things can be refactored to make the code easier and shorter

BTW we cannot just plug in git-merge-tree yet, because git-merge-tree
does not handle renames at all.

This patch is meant for testing, and as such,

- it compile the program to git-merge-recur
- it adjusts the scripts and tests to use git-merge-recur instead of
  git-merge-recursive
- it provides "TEST", a script to execute the tests regarding -recursive
- it inlines the changes to read-cache.c (read_cache_from(), discard_cache()
  and refresh_cache_entry())

Brought to you by Alex Riesen and Dscho

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 23:10:19 -07:00