Automatic merge of /home/torvalds/junkio/.git/
This commit is contained in:
commit
54c26fb9d0
3
Makefile
3
Makefile
@ -21,7 +21,7 @@ PROG= git-update-cache git-diff-files git-init-db git-write-tree \
|
|||||||
git-check-files git-ls-tree git-merge-base git-merge-cache \
|
git-check-files git-ls-tree git-merge-base git-merge-cache \
|
||||||
git-unpack-file git-export git-diff-cache git-convert-cache \
|
git-unpack-file git-export git-diff-cache git-convert-cache \
|
||||||
git-http-pull git-rpush git-rpull git-rev-list git-mktag \
|
git-http-pull git-rpush git-rpull git-rev-list git-mktag \
|
||||||
git-diff-tree-helper git-tar-tree git-local-pull
|
git-diff-tree-helper git-tar-tree git-local-pull git-write-blob
|
||||||
|
|
||||||
all: $(PROG)
|
all: $(PROG)
|
||||||
|
|
||||||
@ -94,6 +94,7 @@ git-rev-list: rev-list.c
|
|||||||
git-mktag: mktag.c
|
git-mktag: mktag.c
|
||||||
git-diff-tree-helper: diff-tree-helper.c
|
git-diff-tree-helper: diff-tree-helper.c
|
||||||
git-tar-tree: tar-tree.c
|
git-tar-tree: tar-tree.c
|
||||||
|
git-write-blob: write-blob.c
|
||||||
|
|
||||||
git-http-pull: LIBS += -lcurl
|
git-http-pull: LIBS += -lcurl
|
||||||
|
|
||||||
|
1
cache.h
1
cache.h
@ -116,6 +116,7 @@ extern int remove_entry_at(int pos);
|
|||||||
extern int remove_file_from_cache(char *path);
|
extern int remove_file_from_cache(char *path);
|
||||||
extern int same_name(struct cache_entry *a, struct cache_entry *b);
|
extern int same_name(struct cache_entry *a, struct cache_entry *b);
|
||||||
extern int cache_match_stat(struct cache_entry *ce, struct stat *st);
|
extern int cache_match_stat(struct cache_entry *ce, struct stat *st);
|
||||||
|
extern int index_fd(unsigned char *sha1, int fd, struct stat *st);
|
||||||
|
|
||||||
#define MTIME_CHANGED 0x0001
|
#define MTIME_CHANGED 0x0001
|
||||||
#define CTIME_CHANGED 0x0002
|
#define CTIME_CHANGED 0x0002
|
||||||
|
0
git-apply-patch-script
Normal file → Executable file
0
git-apply-patch-script
Normal file → Executable file
@ -6,81 +6,69 @@
|
|||||||
# $2 - file in branch1 SHA1 (or empty)
|
# $2 - file in branch1 SHA1 (or empty)
|
||||||
# $3 - file in branch2 SHA1 (or empty)
|
# $3 - file in branch2 SHA1 (or empty)
|
||||||
# $4 - pathname in repository
|
# $4 - pathname in repository
|
||||||
#
|
# $5 - orignal file mode (or empty)
|
||||||
|
# $6 - file in branch1 mode (or empty)
|
||||||
|
# $7 - file in branch2 mode (or empty)
|
||||||
#
|
#
|
||||||
# Handle some trivial cases.. The _really_ trivial cases have
|
# Handle some trivial cases.. The _really_ trivial cases have
|
||||||
# been handled already by git-read-tree, but that one doesn't
|
# been handled already by git-read-tree, but that one doesn't
|
||||||
# do any merges that migth change the tree layout
|
# do any merges that migth change the tree layout.
|
||||||
#
|
|
||||||
|
|
||||||
# if the directory is newly added in a branch, it might not exist
|
|
||||||
# in the current tree
|
|
||||||
dir=$(dirname "$4")
|
|
||||||
mkdir -p "$dir" || exit
|
|
||||||
|
|
||||||
case "${1:-.}${2:-.}${3:-.}" in
|
case "${1:-.}${2:-.}${3:-.}" in
|
||||||
#
|
#
|
||||||
# deleted in both
|
# Deleted in both.
|
||||||
#
|
#
|
||||||
"$1..")
|
"$1..")
|
||||||
echo "ERROR: $4 is removed in both branches"
|
echo "ERROR: $4 is removed in both branches."
|
||||||
echo "ERROR: This is a potential rename conflict"
|
echo "ERROR: This is a potential rename conflict."
|
||||||
exit 1;;
|
exit 1;;
|
||||||
#
|
#
|
||||||
# deleted in one and unchanged in the other
|
# Deleted in one and unchanged in the other.
|
||||||
#
|
#
|
||||||
"$1.." | "$1.$1" | "$1$1.")
|
"$1.." | "$1.$1" | "$1$1.")
|
||||||
echo "Removing $4"
|
echo "Removing $4"
|
||||||
rm -f -- "$4" && exec git-update-cache --remove -- "$4" ;;
|
exec git-update-cache --force-remove "$4" ;;
|
||||||
#
|
#
|
||||||
# added in one
|
# Added in one.
|
||||||
#
|
#
|
||||||
".$2." | "..$3" )
|
".$2." | "..$3" )
|
||||||
case "$6$7" in *7??) mode=+x;; *) mode=-x;; esac
|
case "$6$7" in *7??) mode=+x;; *) mode=-x;; esac
|
||||||
echo "Adding $4 with perm $mode"
|
echo "Adding $4 with perm $mode."
|
||||||
rm -f -- "$4" &&
|
exec git-update-cache --add --cacheinfo "$6$7" "$2$3" "$4" ;;
|
||||||
git-cat-file blob "$2$3" >"$4" &&
|
|
||||||
chmod "$mode" -- "$4" &&
|
|
||||||
exec git-update-cache --add -- "$4" ;;
|
|
||||||
#
|
#
|
||||||
# Added in both (check for same permissions)
|
# Added in both (check for same permissions).
|
||||||
#
|
#
|
||||||
".$2$2")
|
".$3$2")
|
||||||
if [ "$6" != "$7" ]; then
|
if [ "$6" != "$7" ]; then
|
||||||
echo "ERROR: File $4 added in both branches, permissions conflict $6->$7"
|
echo "ERROR: File $4 added identically in both branches,"
|
||||||
|
echo "ERROR: but permissions conflict $6->$7."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
case "$6" in *7??) mode=+x;; *) mode=-x;; esac
|
case "$6" in *7??) mode=+x;; *) mode=-x;; esac
|
||||||
echo "Adding $4 with perm $mode"
|
echo "Adding $4 with perm $mode"
|
||||||
rm -f -- "$4" &&
|
exec git-update-cache --add --cacheinfo "$6" "$2" "$4" ;;
|
||||||
git-cat-file blob "$2" >"$4" &&
|
|
||||||
chmod "$mode" -- "$4" &&
|
|
||||||
exec git-update-cache --add -- "$4" ;;
|
|
||||||
#
|
#
|
||||||
# Modified in both, but differently ;(
|
# Modified in both, but differently.
|
||||||
#
|
#
|
||||||
"$1$2$3")
|
"$1$2$3")
|
||||||
echo "Auto-merging $4"
|
echo "Auto-merging $4."
|
||||||
orig=$(git-unpack-file $1)
|
orig=$(git-unpack-file $1)
|
||||||
src1=$(git-unpack-file $2)
|
src1=$(git-unpack-file $2)
|
||||||
src2=$(git-unpack-file $3)
|
src2=$(git-unpack-file $3)
|
||||||
merge "$src2" "$orig" "$src1"
|
merge "$src2" "$orig" "$src1"
|
||||||
ret=$?
|
ret=$?
|
||||||
if [ "$6" != "$7" ]; then
|
if [ "$6" != "$7" ]; then
|
||||||
echo "ERROR: Permissions $5->$6->$7 don't match merging $src2"
|
echo "ERROR: Permissions $5->$6->$7 don't match."
|
||||||
if [ $ret -ne 0 ]; then
|
|
||||||
echo "ERROR: Leaving conflict merge in $src2"
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
if [ $ret -ne 0 ]; then
|
if [ $ret -ne 0 ]; then
|
||||||
echo "ERROR: Leaving conflict merge in $src2"
|
echo "ERROR: Leaving conflict merge in $src2."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
case "$6" in *7??) mode=+x;; *) mode=-x;; esac
|
sha1=$(git-write-blob "$src2") || {
|
||||||
rm -f -- "$4" && cat "$src2" >"$4" && chmod "$mode" -- "$4" &&
|
echo "ERROR: Leaving conflict merge in $src2."
|
||||||
exec git-update-cache --add -- "$4" ;;
|
}
|
||||||
|
exec git-update-cache --add --cacheinfo "$6" $sha1 "$4" ;;
|
||||||
*)
|
*)
|
||||||
echo "Not handling case $4: $1 -> $2 -> $3" ;;
|
echo "ERROR: Not handling case $4: $1 -> $2 -> $3" ;;
|
||||||
esac
|
esac
|
||||||
exit 1
|
exit 1
|
||||||
|
51
sha1_file.c
51
sha1_file.c
@ -460,3 +460,54 @@ int has_sha1_file(const unsigned char *sha1)
|
|||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int index_fd(unsigned char *sha1, int fd, struct stat *st)
|
||||||
|
{
|
||||||
|
z_stream stream;
|
||||||
|
unsigned long size = st->st_size;
|
||||||
|
int max_out_bytes = size + 200;
|
||||||
|
void *out = xmalloc(max_out_bytes);
|
||||||
|
void *metadata = xmalloc(200);
|
||||||
|
int metadata_size;
|
||||||
|
void *in;
|
||||||
|
SHA_CTX c;
|
||||||
|
|
||||||
|
in = "";
|
||||||
|
if (size)
|
||||||
|
in = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
|
close(fd);
|
||||||
|
if (!out || (int)(long)in == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
metadata_size = 1+sprintf(metadata, "blob %lu", size);
|
||||||
|
|
||||||
|
SHA1_Init(&c);
|
||||||
|
SHA1_Update(&c, metadata, metadata_size);
|
||||||
|
SHA1_Update(&c, in, size);
|
||||||
|
SHA1_Final(sha1, &c);
|
||||||
|
|
||||||
|
memset(&stream, 0, sizeof(stream));
|
||||||
|
deflateInit(&stream, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ASCII size + nul byte
|
||||||
|
*/
|
||||||
|
stream.next_in = metadata;
|
||||||
|
stream.avail_in = metadata_size;
|
||||||
|
stream.next_out = out;
|
||||||
|
stream.avail_out = max_out_bytes;
|
||||||
|
while (deflate(&stream, 0) == Z_OK)
|
||||||
|
/* nothing */;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File content
|
||||||
|
*/
|
||||||
|
stream.next_in = in;
|
||||||
|
stream.avail_in = size;
|
||||||
|
while (deflate(&stream, Z_FINISH) == Z_OK)
|
||||||
|
/*nothing */;
|
||||||
|
|
||||||
|
deflateEnd(&stream);
|
||||||
|
|
||||||
|
return write_sha1_buffer(sha1, out, stream.total_out);
|
||||||
|
}
|
||||||
|
@ -31,57 +31,6 @@ static inline long IS_ERR(const void *ptr)
|
|||||||
return (unsigned long)ptr > (unsigned long)-1000L;
|
return (unsigned long)ptr > (unsigned long)-1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int index_fd(unsigned char *sha1, int fd, struct stat *st)
|
|
||||||
{
|
|
||||||
z_stream stream;
|
|
||||||
unsigned long size = st->st_size;
|
|
||||||
int max_out_bytes = size + 200;
|
|
||||||
void *out = xmalloc(max_out_bytes);
|
|
||||||
void *metadata = xmalloc(200);
|
|
||||||
int metadata_size;
|
|
||||||
void *in;
|
|
||||||
SHA_CTX c;
|
|
||||||
|
|
||||||
in = "";
|
|
||||||
if (size)
|
|
||||||
in = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
|
|
||||||
close(fd);
|
|
||||||
if (!out || (int)(long)in == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
metadata_size = 1+sprintf(metadata, "blob %lu", size);
|
|
||||||
|
|
||||||
SHA1_Init(&c);
|
|
||||||
SHA1_Update(&c, metadata, metadata_size);
|
|
||||||
SHA1_Update(&c, in, size);
|
|
||||||
SHA1_Final(sha1, &c);
|
|
||||||
|
|
||||||
memset(&stream, 0, sizeof(stream));
|
|
||||||
deflateInit(&stream, Z_BEST_COMPRESSION);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ASCII size + nul byte
|
|
||||||
*/
|
|
||||||
stream.next_in = metadata;
|
|
||||||
stream.avail_in = metadata_size;
|
|
||||||
stream.next_out = out;
|
|
||||||
stream.avail_out = max_out_bytes;
|
|
||||||
while (deflate(&stream, 0) == Z_OK)
|
|
||||||
/* nothing */;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* File content
|
|
||||||
*/
|
|
||||||
stream.next_in = in;
|
|
||||||
stream.avail_in = size;
|
|
||||||
while (deflate(&stream, Z_FINISH) == Z_OK)
|
|
||||||
/*nothing */;
|
|
||||||
|
|
||||||
deflateEnd(&stream);
|
|
||||||
|
|
||||||
return write_sha1_buffer(sha1, out, stream.total_out);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This only updates the "non-critical" parts of the directory
|
* This only updates the "non-critical" parts of the directory
|
||||||
* cache, ie the parts that aren't tracked by GIT, and only used
|
* cache, ie the parts that aren't tracked by GIT, and only used
|
||||||
@ -357,6 +306,15 @@ int main(int argc, char **argv)
|
|||||||
i += 3;
|
i += 3;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(path, "--force-remove")) {
|
||||||
|
if (argc <= i + 1)
|
||||||
|
die("update-cache: --force-remove <path>");
|
||||||
|
if (remove_file_from_cache(argv[i+1]))
|
||||||
|
die("update-cache: --force-remove cannot remove %s", argv[i+1]);
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(path, "--ignore-missing")) {
|
if (!strcmp(path, "--ignore-missing")) {
|
||||||
not_new = 1;
|
not_new = 1;
|
||||||
continue;
|
continue;
|
||||||
|
25
write-blob.c
Normal file
25
write-blob.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* GIT - The information manager from hell
|
||||||
|
*
|
||||||
|
* Copyright (C) Linus Torvalds, 2005
|
||||||
|
*/
|
||||||
|
#include "cache.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 1 ; i < argc; i++) {
|
||||||
|
char *path = argv[i];
|
||||||
|
int fd;
|
||||||
|
struct stat st;
|
||||||
|
unsigned char sha1[20];
|
||||||
|
fd = open(path, O_RDONLY);
|
||||||
|
if (fd < 0 ||
|
||||||
|
fstat(fd, &st) < 0 ||
|
||||||
|
index_fd(sha1, fd, &st) < 0)
|
||||||
|
die("Unable to add blob %s to database", path);
|
||||||
|
printf("%s\n", sha1_to_hex(sha1));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user