Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
17dff84b5e | |||
36cd2cc7d9 | |||
e9add36007 | |||
8eafa3da62 | |||
08337a97a2 | |||
e5f5219a4f | |||
975b31dc6e | |||
c97451ce09 | |||
7e4a2a8483 | |||
7d6fb370bc | |||
6ab58895cd | |||
ac44f3e7c0 | |||
9a84074d08 | |||
695bf722da | |||
bb5ebed731 | |||
c5ced64578 | |||
c63da8d8e8 | |||
1e80e04492 | |||
a14c225661 | |||
e99fcf96de | |||
69310a34cb | |||
7246ed438c | |||
f4a11066cf | |||
8d712aafd2 | |||
8ac4838af4 | |||
50e7b06730 |
@ -13,7 +13,8 @@ SYNOPSIS
|
|||||||
(-[c|d|o|i|s|u|k|m])\*
|
(-[c|d|o|i|s|u|k|m])\*
|
||||||
[-x <pattern>|--exclude=<pattern>]
|
[-x <pattern>|--exclude=<pattern>]
|
||||||
[-X <file>|--exclude-from=<file>]
|
[-X <file>|--exclude-from=<file>]
|
||||||
[--exclude-per-directory=<file>] [--] [<file>]\*
|
[--exclude-per-directory=<file>]
|
||||||
|
[--full-name] [--] [<file>]\*
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@ -77,6 +78,12 @@ OPTIONS
|
|||||||
K:: to be killed
|
K:: to be killed
|
||||||
? other
|
? other
|
||||||
|
|
||||||
|
--full-name::
|
||||||
|
When run from a subdirectory, the command usually
|
||||||
|
outputs paths relative to the current directory. This
|
||||||
|
option forces paths to be output relative to the project
|
||||||
|
top directory.
|
||||||
|
|
||||||
--::
|
--::
|
||||||
Do not interpret any more arguments as options.
|
Do not interpret any more arguments as options.
|
||||||
|
|
||||||
|
5
Makefile
5
Makefile
@ -55,7 +55,7 @@ all:
|
|||||||
# Define USE_STDEV below if you want git to care about the underlying device
|
# Define USE_STDEV below if you want git to care about the underlying device
|
||||||
# change being considered an inode change from the update-cache perspective.
|
# change being considered an inode change from the update-cache perspective.
|
||||||
|
|
||||||
GIT_VERSION = 1.0.0a
|
GIT_VERSION = 1.0.6
|
||||||
|
|
||||||
# CFLAGS and LDFLAGS are for the users to override from the command line.
|
# CFLAGS and LDFLAGS are for the users to override from the command line.
|
||||||
|
|
||||||
@ -397,6 +397,9 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
|
|||||||
git-cherry-pick: git-revert
|
git-cherry-pick: git-revert
|
||||||
cp $< $@
|
cp $< $@
|
||||||
|
|
||||||
|
# format-patch records GIT_VERSION
|
||||||
|
git-format-patch: Makefile
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
|
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
|
3
commit.c
3
commit.c
@ -560,6 +560,9 @@ void sort_in_topological_order(struct commit_list ** list)
|
|||||||
next = next->next;
|
next = next->next;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
return;
|
||||||
/* allocate an array to help sort the list */
|
/* allocate an array to help sort the list */
|
||||||
nodes = xcalloc(count, sizeof(*nodes));
|
nodes = xcalloc(count, sizeof(*nodes));
|
||||||
/* link the list to the array */
|
/* link the list to the array */
|
||||||
|
2
config.c
2
config.c
@ -487,7 +487,7 @@ int git_config_set_multivar(const char* key, const char* value,
|
|||||||
store.value_regex = (regex_t*)malloc(sizeof(regex_t));
|
store.value_regex = (regex_t*)malloc(sizeof(regex_t));
|
||||||
if (regcomp(store.value_regex, value_regex,
|
if (regcomp(store.value_regex, value_regex,
|
||||||
REG_EXTENDED)) {
|
REG_EXTENDED)) {
|
||||||
fprintf(stderr, "Invalid pattern: %s",
|
fprintf(stderr, "Invalid pattern: %s\n",
|
||||||
value_regex);
|
value_regex);
|
||||||
free(store.value_regex);
|
free(store.value_regex);
|
||||||
return 6;
|
return 6;
|
||||||
|
7
copy.c
7
copy.c
@ -22,11 +22,14 @@ int copy_fd(int ifd, int ofd)
|
|||||||
buf += written;
|
buf += written;
|
||||||
len -= written;
|
len -= written;
|
||||||
}
|
}
|
||||||
else if (!written)
|
else if (!written) {
|
||||||
|
close(ifd);
|
||||||
return error("copy-fd: write returned 0");
|
return error("copy-fd: write returned 0");
|
||||||
else
|
} else {
|
||||||
|
close(ifd);
|
||||||
return error("copy-fd: write returned %s",
|
return error("copy-fd: write returned %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(ifd);
|
close(ifd);
|
||||||
|
18
debian/changelog
vendored
18
debian/changelog
vendored
@ -1,3 +1,21 @@
|
|||||||
|
git-core (1.0.4-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* GIT 1.0.4.
|
||||||
|
|
||||||
|
-- Junio C Hamano <junkio@cox.net> Sat, 24 Dec 2005 00:01:20 -0800
|
||||||
|
|
||||||
|
git-core (1.0.3-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* GIT 1.0.3 maintenance release.
|
||||||
|
|
||||||
|
-- Junio C Hamano <junkio@cox.net> Thu, 22 Dec 2005 18:13:33 -0800
|
||||||
|
|
||||||
|
git-core (1.0.0b-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* GIT 1.0.0b to include two more fixes.
|
||||||
|
|
||||||
|
-- Junio C Hamano <junkio@cox.net> Wed, 21 Dec 2005 13:50:21 -0800
|
||||||
|
|
||||||
git-core (1.0.0a-0) unstable; urgency=low
|
git-core (1.0.0a-0) unstable; urgency=low
|
||||||
|
|
||||||
* GIT 1.0.0a to include the following fixes:
|
* GIT 1.0.0a to include the following fixes:
|
||||||
|
8
diff.c
8
diff.c
@ -504,9 +504,9 @@ static void prepare_temp_file(const char *name,
|
|||||||
}
|
}
|
||||||
if (S_ISLNK(st.st_mode)) {
|
if (S_ISLNK(st.st_mode)) {
|
||||||
int ret;
|
int ret;
|
||||||
char *buf, buf_[1024];
|
char buf[PATH_MAX + 1]; /* ought to be SYMLINK_MAX */
|
||||||
buf = ((sizeof(buf_) < st.st_size) ?
|
if (sizeof(buf) <= st.st_size)
|
||||||
xmalloc(st.st_size) : buf_);
|
die("symlink too long: %s", name);
|
||||||
ret = readlink(name, buf, st.st_size);
|
ret = readlink(name, buf, st.st_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
die("readlink(%s)", name);
|
die("readlink(%s)", name);
|
||||||
@ -650,7 +650,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
|
|||||||
if (DIFF_FILE_VALID(one)) {
|
if (DIFF_FILE_VALID(one)) {
|
||||||
if (!one->sha1_valid) {
|
if (!one->sha1_valid) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(one->path, &st) < 0)
|
if (lstat(one->path, &st) < 0)
|
||||||
die("stat %s", one->path);
|
die("stat %s", one->path);
|
||||||
if (index_path(one->sha1, one->path, &st, 0))
|
if (index_path(one->sha1, one->path, &st, 0))
|
||||||
die("cannot hash %s\n", one->path);
|
die("cannot hash %s\n", one->path);
|
||||||
|
@ -105,9 +105,13 @@ static int compare_pair_order(const void *a_, const void *b_)
|
|||||||
void diffcore_order(const char *orderfile)
|
void diffcore_order(const char *orderfile)
|
||||||
{
|
{
|
||||||
struct diff_queue_struct *q = &diff_queued_diff;
|
struct diff_queue_struct *q = &diff_queued_diff;
|
||||||
struct pair_order *o = xmalloc(sizeof(*o) * q->nr);
|
struct pair_order *o;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!q->nr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
o = xmalloc(sizeof(*o) * q->nr);
|
||||||
prepare_order(orderfile);
|
prepare_order(orderfile);
|
||||||
for (i = 0; i < q->nr; i++) {
|
for (i = 0; i < q->nr; i++) {
|
||||||
o[i].pair = q->queue[i];
|
o[i].pair = q->queue[i];
|
||||||
|
@ -48,6 +48,9 @@ void diffcore_pathspec(const char **pathspec)
|
|||||||
for (i = 0; pathspec[i]; i++)
|
for (i = 0; pathspec[i]; i++)
|
||||||
;
|
;
|
||||||
speccnt = i;
|
speccnt = i;
|
||||||
|
if (!speccnt)
|
||||||
|
return;
|
||||||
|
|
||||||
spec = xmalloc(sizeof(*spec) * speccnt);
|
spec = xmalloc(sizeof(*spec) * speccnt);
|
||||||
for (i = 0; pathspec[i]; i++) {
|
for (i = 0; pathspec[i]; i++) {
|
||||||
spec[i].spec = pathspec[i];
|
spec[i].spec = pathspec[i];
|
||||||
|
@ -282,7 +282,7 @@ void diffcore_rename(struct diff_options *options)
|
|||||||
else if (detect_rename == DIFF_DETECT_COPY)
|
else if (detect_rename == DIFF_DETECT_COPY)
|
||||||
register_rename_src(p->one, 1);
|
register_rename_src(p->one, 1);
|
||||||
}
|
}
|
||||||
if (rename_dst_nr == 0 ||
|
if (rename_dst_nr == 0 || rename_src_nr == 0 ||
|
||||||
(0 < rename_limit && rename_limit < rename_dst_nr))
|
(0 < rename_limit && rename_limit < rename_dst_nr))
|
||||||
goto cleanup; /* nothing to do */
|
goto cleanup; /* nothing to do */
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ then
|
|||||||
sed -e '
|
sed -e '
|
||||||
/\^/d
|
/\^/d
|
||||||
s/^[^ ]* //
|
s/^[^ ]* //
|
||||||
s/.*/&:&/')
|
s/.*/.&:&/')
|
||||||
if test "$#" -gt 1
|
if test "$#" -gt 1
|
||||||
then
|
then
|
||||||
# remote URL plus explicit refspecs; we need to merge them.
|
# remote URL plus explicit refspecs; we need to merge them.
|
||||||
|
11
git-merge.sh
11
git-merge.sh
@ -209,6 +209,7 @@ case "$use_strategies" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
result_tree= best_cnt=-1 best_strategy= wt_strategy=
|
result_tree= best_cnt=-1 best_strategy= wt_strategy=
|
||||||
|
merge_was_ok=
|
||||||
for strategy in $use_strategies
|
for strategy in $use_strategies
|
||||||
do
|
do
|
||||||
test "$wt_strategy" = '' || {
|
test "$wt_strategy" = '' || {
|
||||||
@ -228,6 +229,7 @@ do
|
|||||||
exit=$?
|
exit=$?
|
||||||
if test "$no_commit" = t && test "$exit" = 0
|
if test "$no_commit" = t && test "$exit" = 0
|
||||||
then
|
then
|
||||||
|
merge_was_ok=t
|
||||||
exit=1 ;# pretend it left conflicts.
|
exit=1 ;# pretend it left conflicts.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -293,4 +295,11 @@ do
|
|||||||
done >"$GIT_DIR/MERGE_HEAD"
|
done >"$GIT_DIR/MERGE_HEAD"
|
||||||
echo $merge_msg >"$GIT_DIR/MERGE_MSG"
|
echo $merge_msg >"$GIT_DIR/MERGE_MSG"
|
||||||
|
|
||||||
die "Automatic merge failed/prevented; fix up by hand"
|
if test "$merge_was_ok" = t
|
||||||
|
then
|
||||||
|
echo >&2 \
|
||||||
|
"Automatic merge went well; stopped before committing as requested"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
die "Automatic merge failed; fix up by hand"
|
||||||
|
fi
|
||||||
|
2
git.c
2
git.c
@ -278,7 +278,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
if (*exec_path != '/') {
|
if (*exec_path != '/') {
|
||||||
if (!getcwd(git_command, sizeof(git_command))) {
|
if (!getcwd(git_command, sizeof(git_command))) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"git: cannot determine current directory");
|
"git: cannot determine current directory\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
len = strlen(git_command);
|
len = strlen(git_command);
|
||||||
|
12
http-fetch.c
12
http-fetch.c
@ -267,7 +267,8 @@ static void process_object_response(void *callback_data)
|
|||||||
obj_req->state = COMPLETE;
|
obj_req->state = COMPLETE;
|
||||||
|
|
||||||
/* Use alternates if necessary */
|
/* Use alternates if necessary */
|
||||||
if (obj_req->http_code == 404) {
|
if (obj_req->http_code == 404 ||
|
||||||
|
obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
|
||||||
fetch_alternates(alt->base);
|
fetch_alternates(alt->base);
|
||||||
if (obj_req->repo->next != NULL) {
|
if (obj_req->repo->next != NULL) {
|
||||||
obj_req->repo =
|
obj_req->repo =
|
||||||
@ -475,7 +476,8 @@ static void process_alternates_response(void *callback_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (slot->curl_result != CURLE_OK) {
|
} else if (slot->curl_result != CURLE_OK) {
|
||||||
if (slot->http_code != 404) {
|
if (slot->http_code != 404 &&
|
||||||
|
slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
|
||||||
got_alternates = -1;
|
got_alternates = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -637,7 +639,8 @@ static int fetch_indices(struct alt_base *repo)
|
|||||||
if (start_active_slot(slot)) {
|
if (start_active_slot(slot)) {
|
||||||
run_active_slot(slot);
|
run_active_slot(slot);
|
||||||
if (slot->curl_result != CURLE_OK) {
|
if (slot->curl_result != CURLE_OK) {
|
||||||
if (slot->http_code == 404) {
|
if (slot->http_code == 404 ||
|
||||||
|
slot->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
|
||||||
repo->got_indices = 1;
|
repo->got_indices = 1;
|
||||||
free(buffer.buffer);
|
free(buffer.buffer);
|
||||||
return 0;
|
return 0;
|
||||||
@ -802,7 +805,8 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
|
|||||||
ret = error("Request for %s aborted", hex);
|
ret = error("Request for %s aborted", hex);
|
||||||
} else if (obj_req->curl_result != CURLE_OK &&
|
} else if (obj_req->curl_result != CURLE_OK &&
|
||||||
obj_req->http_code != 416) {
|
obj_req->http_code != 416) {
|
||||||
if (obj_req->http_code == 404)
|
if (obj_req->http_code == 404 ||
|
||||||
|
obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)
|
||||||
ret = -1; /* Be silent, it is probably in a pack. */
|
ret = -1; /* Be silent, it is probably in a pack. */
|
||||||
else
|
else
|
||||||
ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
|
ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
|
||||||
|
22
index-pack.c
22
index-pack.c
@ -352,18 +352,24 @@ static int sha1_compare(const void *_a, const void *_b)
|
|||||||
static void write_index_file(const char *index_name, unsigned char *sha1)
|
static void write_index_file(const char *index_name, unsigned char *sha1)
|
||||||
{
|
{
|
||||||
struct sha1file *f;
|
struct sha1file *f;
|
||||||
struct object_entry **sorted_by_sha =
|
struct object_entry **sorted_by_sha, **list, **last;
|
||||||
xcalloc(nr_objects, sizeof(struct object_entry *));
|
|
||||||
struct object_entry **list = sorted_by_sha;
|
|
||||||
struct object_entry **last = sorted_by_sha + nr_objects;
|
|
||||||
unsigned int array[256];
|
unsigned int array[256];
|
||||||
int i;
|
int i;
|
||||||
SHA_CTX ctx;
|
SHA_CTX ctx;
|
||||||
|
|
||||||
for (i = 0; i < nr_objects; ++i)
|
if (nr_objects) {
|
||||||
sorted_by_sha[i] = &objects[i];
|
sorted_by_sha =
|
||||||
qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
|
xcalloc(nr_objects, sizeof(struct object_entry *));
|
||||||
sha1_compare);
|
list = sorted_by_sha;
|
||||||
|
last = sorted_by_sha + nr_objects;
|
||||||
|
for (i = 0; i < nr_objects; ++i)
|
||||||
|
sorted_by_sha[i] = &objects[i];
|
||||||
|
qsort(sorted_by_sha, nr_objects, sizeof(sorted_by_sha[0]),
|
||||||
|
sha1_compare);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sorted_by_sha = list = last = NULL;
|
||||||
|
|
||||||
unlink(index_name);
|
unlink(index_name);
|
||||||
f = sha1create("%s", index_name);
|
f = sha1create("%s", index_name);
|
||||||
|
@ -562,7 +562,7 @@ static void verify_pathspec(void)
|
|||||||
static const char ls_files_usage[] =
|
static const char ls_files_usage[] =
|
||||||
"git-ls-files [-z] [-t] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
|
"git-ls-files [-z] [-t] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
|
||||||
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
|
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
|
||||||
"[ --exclude-per-directory=<filename> ] [--] [<file>]*";
|
"[ --exclude-per-directory=<filename> ] [--full-name] [--] [<file>]*";
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
|
@ -472,7 +472,7 @@ static void convert_to_utf8(char *line, char *charset)
|
|||||||
char *in, *out;
|
char *in, *out;
|
||||||
size_t insize, outsize, nrc;
|
size_t insize, outsize, nrc;
|
||||||
char outbuf[4096]; /* cheat */
|
char outbuf[4096]; /* cheat */
|
||||||
static char latin_one[] = "latin-1";
|
static char latin_one[] = "latin1";
|
||||||
char *input_charset = *charset ? charset : latin_one;
|
char *input_charset = *charset ? charset : latin_one;
|
||||||
iconv_t conv = iconv_open(metainfo_charset, input_charset);
|
iconv_t conv = iconv_open(metainfo_charset, input_charset);
|
||||||
|
|
||||||
|
6
quote.c
6
quote.c
@ -126,8 +126,10 @@ static int quote_c_style_counted(const char *name, int namelen,
|
|||||||
|
|
||||||
if (!no_dq)
|
if (!no_dq)
|
||||||
EMIT('"');
|
EMIT('"');
|
||||||
for (sp = name; (ch = *sp++) && (sp - name) <= namelen; ) {
|
for (sp = name; sp < name + namelen; sp++) {
|
||||||
|
ch = *sp;
|
||||||
|
if (!ch)
|
||||||
|
break;
|
||||||
if ((ch < ' ') || (ch == '"') || (ch == '\\') ||
|
if ((ch < ' ') || (ch == '"') || (ch == '\\') ||
|
||||||
(ch == 0177)) {
|
(ch == 0177)) {
|
||||||
needquote = 1;
|
needquote = 1;
|
||||||
|
17
read-tree.c
17
read-tree.c
@ -294,17 +294,20 @@ static int unpack_trees(merge_fn_t fn)
|
|||||||
{
|
{
|
||||||
int indpos = 0;
|
int indpos = 0;
|
||||||
unsigned len = object_list_length(trees);
|
unsigned len = object_list_length(trees);
|
||||||
struct tree_entry_list **posns =
|
struct tree_entry_list **posns;
|
||||||
xmalloc(len * sizeof(struct tree_entry_list *));
|
|
||||||
int i;
|
int i;
|
||||||
struct object_list *posn = trees;
|
struct object_list *posn = trees;
|
||||||
merge_size = len;
|
merge_size = len;
|
||||||
for (i = 0; i < len; i++) {
|
|
||||||
posns[i] = ((struct tree *) posn->item)->entries;
|
if (len) {
|
||||||
posn = posn->next;
|
posns = xmalloc(len * sizeof(struct tree_entry_list *));
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
posns[i] = ((struct tree *) posn->item)->entries;
|
||||||
|
posn = posn->next;
|
||||||
|
}
|
||||||
|
if (unpack_trees_rec(posns, len, "", fn, &indpos))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
if (unpack_trees_rec(posns, len, "", fn, &indpos))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (trivial_merges_only && nontrivial_merge)
|
if (trivial_merges_only && nontrivial_merge)
|
||||||
die("Merge requires file-level merging");
|
die("Merge requires file-level merging");
|
||||||
|
@ -79,7 +79,7 @@ static int run_update_hook(const char *refname,
|
|||||||
case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
|
case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
|
||||||
die("waitpid is confused");
|
die("waitpid is confused");
|
||||||
case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
|
case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
|
||||||
fprintf(stderr, "%s died of signal", update_hook);
|
fprintf(stderr, "%s died of signal\n", update_hook);
|
||||||
return -1;
|
return -1;
|
||||||
case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
|
case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
|
||||||
die("%s died strangely", update_hook);
|
die("%s died strangely", update_hook);
|
||||||
|
30
send-pack.c
30
send-pack.c
@ -231,23 +231,21 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
|
|||||||
if (!force_update &&
|
if (!force_update &&
|
||||||
!is_zero_sha1(ref->old_sha1) &&
|
!is_zero_sha1(ref->old_sha1) &&
|
||||||
!ref->force) {
|
!ref->force) {
|
||||||
if (!has_sha1_file(ref->old_sha1)) {
|
if (!has_sha1_file(ref->old_sha1) ||
|
||||||
error("remote '%s' object %s does not "
|
!ref_newer(ref->peer_ref->new_sha1,
|
||||||
"exist on local",
|
|
||||||
ref->name, sha1_to_hex(ref->old_sha1));
|
|
||||||
ret = -2;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We assume that local is fsck-clean. Otherwise
|
|
||||||
* you _could_ have an old tag which points at
|
|
||||||
* something you do not have, which may or may not
|
|
||||||
* be a commit.
|
|
||||||
*/
|
|
||||||
if (!ref_newer(ref->peer_ref->new_sha1,
|
|
||||||
ref->old_sha1)) {
|
ref->old_sha1)) {
|
||||||
error("remote ref '%s' is not a strict "
|
/* We do not have the remote ref, or
|
||||||
"subset of local ref '%s'.", ref->name,
|
* we know that the remote ref is not
|
||||||
|
* an ancestor of what we are trying to
|
||||||
|
* push. Either way this can be losing
|
||||||
|
* commits at the remote end and likely
|
||||||
|
* we were not up to date to begin with.
|
||||||
|
*/
|
||||||
|
error("remote '%s' is not a strict "
|
||||||
|
"subset of local ref '%s'. "
|
||||||
|
"maybe you are not up-to-date and "
|
||||||
|
"need to pull first?",
|
||||||
|
ref->name,
|
||||||
ref->peer_ref->name);
|
ref->peer_ref->name);
|
||||||
ret = -2;
|
ret = -2;
|
||||||
continue;
|
continue;
|
||||||
|
@ -99,7 +99,10 @@ static int read_pack_info_file(const char *infofile)
|
|||||||
while (fgets(line, sizeof(line), fp)) {
|
while (fgets(line, sizeof(line), fp)) {
|
||||||
int len = strlen(line);
|
int len = strlen(line);
|
||||||
if (line[len-1] == '\n')
|
if (line[len-1] == '\n')
|
||||||
line[len-1] = 0;
|
line[--len] = 0;
|
||||||
|
|
||||||
|
if (!len)
|
||||||
|
continue;
|
||||||
|
|
||||||
switch (line[0]) {
|
switch (line[0]) {
|
||||||
case 'P': /* P name */
|
case 'P': /* P name */
|
||||||
|
28
sha1_file.c
28
sha1_file.c
@ -81,6 +81,8 @@ char * sha1_to_hex(const unsigned char *sha1)
|
|||||||
*buf++ = hex[val >> 4];
|
*buf++ = hex[val >> 4];
|
||||||
*buf++ = hex[val & 0xf];
|
*buf++ = hex[val & 0xf];
|
||||||
}
|
}
|
||||||
|
*buf = '\0';
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,12 +321,16 @@ struct packed_git *packed_git;
|
|||||||
static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
|
static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
|
||||||
void **idx_map_)
|
void **idx_map_)
|
||||||
{
|
{
|
||||||
|
SHA_CTX ctx;
|
||||||
|
unsigned char sha1[20];
|
||||||
void *idx_map;
|
void *idx_map;
|
||||||
unsigned int *index;
|
unsigned int *index;
|
||||||
unsigned long idx_size;
|
unsigned long idx_size;
|
||||||
int nr, i;
|
int nr, i;
|
||||||
int fd = open(path, O_RDONLY);
|
int fd;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
fd = open(path, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (fstat(fd, &st)) {
|
if (fstat(fd, &st)) {
|
||||||
@ -362,6 +368,16 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
|
|||||||
if (idx_size != 4*256 + nr * 24 + 20 + 20)
|
if (idx_size != 4*256 + nr * 24 + 20 + 20)
|
||||||
return error("wrong index file size");
|
return error("wrong index file size");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File checksum.
|
||||||
|
*/
|
||||||
|
SHA1_Init(&ctx);
|
||||||
|
SHA1_Update(&ctx, idx_map, idx_size-20);
|
||||||
|
SHA1_Final(sha1, &ctx);
|
||||||
|
|
||||||
|
if (memcmp(sha1, idx_map + idx_size - 20, 20))
|
||||||
|
return error("index checksum mismatch");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +480,7 @@ struct packed_git *add_packed_git(char *path, int path_len, int local)
|
|||||||
p->pack_last_used = 0;
|
p->pack_last_used = 0;
|
||||||
p->pack_use_cnt = 0;
|
p->pack_use_cnt = 0;
|
||||||
p->pack_local = local;
|
p->pack_local = local;
|
||||||
if (!get_sha1_hex(path + path_len - 40 - 4, sha1))
|
if ((path_len > 44) && !get_sha1_hex(path + path_len - 44, sha1))
|
||||||
memcpy(p->sha1, sha1, 20);
|
memcpy(p->sha1, sha1, 20);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -1274,7 +1290,7 @@ int move_temp_to_file(const char *tmpfile, char *filename)
|
|||||||
unlink(tmpfile);
|
unlink(tmpfile);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret != EEXIST) {
|
if (ret != EEXIST) {
|
||||||
fprintf(stderr, "unable to write sha1 filename %s: %s", filename, strerror(ret));
|
fprintf(stderr, "unable to write sha1 filename %s: %s\n", filename, strerror(ret));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* FIXME!!! Collision check here ? */
|
/* FIXME!!! Collision check here ? */
|
||||||
@ -1313,7 +1329,7 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
fprintf(stderr, "sha1 file %s: %s", filename, strerror(errno));
|
fprintf(stderr, "sha1 file %s: %s\n", filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1321,7 +1337,7 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
|
|||||||
|
|
||||||
fd = mkstemp(tmpfile);
|
fd = mkstemp(tmpfile);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "unable to create temporary sha1 filename %s: %s", tmpfile, strerror(errno));
|
fprintf(stderr, "unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1410,7 +1426,7 @@ int write_sha1_to_fd(int fd, const unsigned char *sha1)
|
|||||||
size = write(fd, buf + posn, objsize - posn);
|
size = write(fd, buf + posn, objsize - posn);
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
if (!size) {
|
if (!size) {
|
||||||
fprintf(stderr, "write closed");
|
fprintf(stderr, "write closed\n");
|
||||||
} else {
|
} else {
|
||||||
perror("write ");
|
perror("write ");
|
||||||
}
|
}
|
||||||
|
@ -284,10 +284,54 @@ static void show_one_commit(struct commit *commit, int no_name)
|
|||||||
static char *ref_name[MAX_REVS + 1];
|
static char *ref_name[MAX_REVS + 1];
|
||||||
static int ref_name_cnt;
|
static int ref_name_cnt;
|
||||||
|
|
||||||
|
static const char *find_digit_prefix(const char *s, int *v)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
int ver;
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
for (p = s, ver = 0;
|
||||||
|
'0' <= (ch = *p) && ch <= '9';
|
||||||
|
p++)
|
||||||
|
ver = ver * 10 + ch - '0';
|
||||||
|
*v = ver;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int version_cmp(const char *a, const char *b)
|
||||||
|
{
|
||||||
|
while (1) {
|
||||||
|
int va, vb;
|
||||||
|
|
||||||
|
a = find_digit_prefix(a, &va);
|
||||||
|
b = find_digit_prefix(b, &vb);
|
||||||
|
if (va != vb)
|
||||||
|
return va - vb;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
int ca = *a;
|
||||||
|
int cb = *b;
|
||||||
|
if ('0' <= ca && ca <= '9')
|
||||||
|
ca = 0;
|
||||||
|
if ('0' <= cb && cb <= '9')
|
||||||
|
cb = 0;
|
||||||
|
if (ca != cb)
|
||||||
|
return ca - cb;
|
||||||
|
if (!ca)
|
||||||
|
break;
|
||||||
|
a++;
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
if (!*a && !*b)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int compare_ref_name(const void *a_, const void *b_)
|
static int compare_ref_name(const void *a_, const void *b_)
|
||||||
{
|
{
|
||||||
const char * const*a = a_, * const*b = b_;
|
const char * const*a = a_, * const*b = b_;
|
||||||
return strcmp(*a, *b);
|
return version_cmp(*a, *b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sort_ref_range(int bottom, int top)
|
static void sort_ref_range(int bottom, int top)
|
||||||
@ -299,11 +343,18 @@ static void sort_ref_range(int bottom, int top)
|
|||||||
static int append_ref(const char *refname, const unsigned char *sha1)
|
static int append_ref(const char *refname, const unsigned char *sha1)
|
||||||
{
|
{
|
||||||
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
|
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!commit)
|
if (!commit)
|
||||||
return 0;
|
return 0;
|
||||||
|
/* Avoid adding the same thing twice */
|
||||||
|
for (i = 0; i < ref_name_cnt; i++)
|
||||||
|
if (!strcmp(refname, ref_name[i]))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (MAX_REVS <= ref_name_cnt) {
|
if (MAX_REVS <= ref_name_cnt) {
|
||||||
fprintf(stderr, "warning: ignoring %s; "
|
fprintf(stderr, "warning: ignoring %s; "
|
||||||
"cannot handle more than %d refs",
|
"cannot handle more than %d refs\n",
|
||||||
refname, MAX_REVS);
|
refname, MAX_REVS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -512,19 +563,17 @@ int main(int ac, char **av)
|
|||||||
if (1 < independent + merge_base + (extra != 0))
|
if (1 < independent + merge_base + (extra != 0))
|
||||||
usage(show_branch_usage);
|
usage(show_branch_usage);
|
||||||
|
|
||||||
|
/* If nothing is specified, show all branches by default */
|
||||||
|
if (ac + all_heads + all_tags == 0)
|
||||||
|
all_heads = 1;
|
||||||
|
|
||||||
if (all_heads + all_tags)
|
if (all_heads + all_tags)
|
||||||
snarf_refs(all_heads, all_tags);
|
snarf_refs(all_heads, all_tags);
|
||||||
|
while (0 < ac) {
|
||||||
|
append_one_rev(*av);
|
||||||
|
ac--; av++;
|
||||||
|
}
|
||||||
|
|
||||||
if (ac) {
|
|
||||||
while (0 < ac) {
|
|
||||||
append_one_rev(*av);
|
|
||||||
ac--; av++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* If no revs given, then add heads */
|
|
||||||
snarf_refs(1, 0);
|
|
||||||
}
|
|
||||||
if (!ref_name_cnt) {
|
if (!ref_name_cnt) {
|
||||||
fprintf(stderr, "No revs to be shown.\n");
|
fprintf(stderr, "No revs to be shown.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -537,7 +586,7 @@ int main(int ac, char **av)
|
|||||||
if (MAX_REVS <= num_rev)
|
if (MAX_REVS <= num_rev)
|
||||||
die("cannot handle more than %d revs.", MAX_REVS);
|
die("cannot handle more than %d revs.", MAX_REVS);
|
||||||
if (get_sha1(ref_name[num_rev], revkey))
|
if (get_sha1(ref_name[num_rev], revkey))
|
||||||
die("'%s' is not a valid ref.\n", ref_name[num_rev]);
|
die("'%s' is not a valid ref.", ref_name[num_rev]);
|
||||||
commit = lookup_commit_reference(revkey);
|
commit = lookup_commit_reference(revkey);
|
||||||
if (!commit)
|
if (!commit)
|
||||||
die("cannot find commit %s (%s)",
|
die("cannot find commit %s (%s)",
|
||||||
|
85
t/t4011-diff-symlink.sh
Executable file
85
t/t4011-diff-symlink.sh
Executable file
@ -0,0 +1,85 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2005 Johannes Schindelin
|
||||||
|
#
|
||||||
|
|
||||||
|
test_description='Test diff of symlinks.
|
||||||
|
|
||||||
|
'
|
||||||
|
. ./test-lib.sh
|
||||||
|
. ../diff-lib.sh
|
||||||
|
|
||||||
|
cat > expected << EOF
|
||||||
|
diff --git a/frotz b/frotz
|
||||||
|
new file mode 120000
|
||||||
|
index 0000000..7c465af
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/frotz
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+xyzzy
|
||||||
|
\ No newline at end of file
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'diff new symlink' \
|
||||||
|
'ln -s xyzzy frotz &&
|
||||||
|
git-update-index &&
|
||||||
|
tree=$(git-write-tree) &&
|
||||||
|
git-update-index --add frotz &&
|
||||||
|
GIT_DIFF_OPTS=--unified=0 git-diff-index -M -p $tree > current &&
|
||||||
|
compare_diff_patch current expected'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'diff unchanged symlink' \
|
||||||
|
'tree=$(git-write-tree) &&
|
||||||
|
git-update-index frotz &&
|
||||||
|
test -z "$(git-diff-index --name-only $tree)"'
|
||||||
|
|
||||||
|
cat > expected << EOF
|
||||||
|
diff --git a/frotz b/frotz
|
||||||
|
deleted file mode 120000
|
||||||
|
index 7c465af..0000000
|
||||||
|
--- a/frotz
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1 +0,0 @@
|
||||||
|
-xyzzy
|
||||||
|
\ No newline at end of file
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'diff removed symlink' \
|
||||||
|
'rm frotz &&
|
||||||
|
git-diff-index -M -p $tree > current &&
|
||||||
|
compare_diff_patch current expected'
|
||||||
|
|
||||||
|
cat > expected << EOF
|
||||||
|
diff --git a/frotz b/frotz
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'diff identical, but newly created symlink' \
|
||||||
|
'sleep 1 &&
|
||||||
|
ln -s xyzzy frotz &&
|
||||||
|
git-diff-index -M -p $tree > current &&
|
||||||
|
compare_diff_patch current expected'
|
||||||
|
|
||||||
|
cat > expected << EOF
|
||||||
|
diff --git a/frotz b/frotz
|
||||||
|
index 7c465af..df1db54 120000
|
||||||
|
--- a/frotz
|
||||||
|
+++ b/frotz
|
||||||
|
@@ -1 +1 @@
|
||||||
|
-xyzzy
|
||||||
|
\ No newline at end of file
|
||||||
|
+yxyyz
|
||||||
|
\ No newline at end of file
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'diff different symlink' \
|
||||||
|
'rm frotz &&
|
||||||
|
ln -s yxyyz frotz &&
|
||||||
|
git-diff-index -M -p $tree > current &&
|
||||||
|
compare_diff_patch current expected'
|
||||||
|
|
||||||
|
test_done
|
@ -142,6 +142,7 @@ test_expect_success \
|
|||||||
else :;
|
else :;
|
||||||
fi &&
|
fi &&
|
||||||
|
|
||||||
|
: PACK_SIGNATURE &&
|
||||||
cp test-1-${packname_1}.pack test-3.pack &&
|
cp test-1-${packname_1}.pack test-3.pack &&
|
||||||
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
|
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
|
||||||
if git-verify-pack test-3.idx
|
if git-verify-pack test-3.idx
|
||||||
@ -149,6 +150,7 @@ test_expect_success \
|
|||||||
else :;
|
else :;
|
||||||
fi &&
|
fi &&
|
||||||
|
|
||||||
|
: PACK_VERSION &&
|
||||||
cp test-1-${packname_1}.pack test-3.pack &&
|
cp test-1-${packname_1}.pack test-3.pack &&
|
||||||
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
|
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
|
||||||
if git-verify-pack test-3.idx
|
if git-verify-pack test-3.idx
|
||||||
@ -156,6 +158,7 @@ test_expect_success \
|
|||||||
else :;
|
else :;
|
||||||
fi &&
|
fi &&
|
||||||
|
|
||||||
|
: TYPE/SIZE byte of the first packed object data &&
|
||||||
cp test-1-${packname_1}.pack test-3.pack &&
|
cp test-1-${packname_1}.pack test-3.pack &&
|
||||||
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
|
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
|
||||||
if git-verify-pack test-3.idx
|
if git-verify-pack test-3.idx
|
||||||
@ -163,6 +166,16 @@ test_expect_success \
|
|||||||
else :;
|
else :;
|
||||||
fi &&
|
fi &&
|
||||||
|
|
||||||
|
: sum of the index file itself &&
|
||||||
|
l=`wc -c <test-3.idx` &&
|
||||||
|
l=`expr $l - 20` &&
|
||||||
|
cp test-1-${packname_1}.pack test-3.pack &&
|
||||||
|
dd if=/dev/zero of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
|
||||||
|
if git-verify-pack test-3.pack
|
||||||
|
then false
|
||||||
|
else :;
|
||||||
|
fi &&
|
||||||
|
|
||||||
:'
|
:'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
|
@ -110,7 +110,7 @@ save_tag g4 unique_commit g6 tree -p g3 -p h2
|
|||||||
|
|
||||||
git-update-ref HEAD $(tag l5)
|
git-update-ref HEAD $(tag l5)
|
||||||
|
|
||||||
test_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -s " "' <<EOF
|
test_output_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -d \" \"' <<EOF
|
||||||
19
|
19
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ save_tag g4 unique_commit g6 tree -p g3 -p h2
|
|||||||
|
|
||||||
git-update-ref HEAD $(tag l5)
|
git-update-ref HEAD $(tag l5)
|
||||||
|
|
||||||
test_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -s " "' <<EOF
|
test_output_expect_success 'rev-list has correct number of entries' 'git-rev-list HEAD | wc -l | tr -d \" \"' <<EOF
|
||||||
19
|
19
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -263,6 +263,10 @@ void diff_tree_setup_paths(const char **p)
|
|||||||
|
|
||||||
paths = p;
|
paths = p;
|
||||||
nr_paths = count_paths(paths);
|
nr_paths = count_paths(paths);
|
||||||
|
if (nr_paths == 0) {
|
||||||
|
pathlens = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
pathlens = xmalloc(nr_paths * sizeof(int));
|
pathlens = xmalloc(nr_paths * sizeof(int));
|
||||||
for (i=0; i<nr_paths; i++)
|
for (i=0; i<nr_paths; i++)
|
||||||
pathlens[i] = strlen(paths[i]);
|
pathlens[i] = strlen(paths[i]);
|
||||||
|
Reference in New Issue
Block a user