summaryrefslogtreecommitdiff
path: root/lib/git
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/index.py13
-rw-r--r--lib/git/objects/commit.py4
-rw-r--r--lib/git/repo.py2
3 files changed, 10 insertions, 9 deletions
diff --git a/lib/git/index.py b/lib/git/index.py
index 0a5ba5a9..1b5d3180 100644
--- a/lib/git/index.py
+++ b/lib/git/index.py
@@ -907,8 +907,9 @@ class IndexFile(LazyMixin, diff.Diffable):
must be a path relative to our repository.
If their sha is null ( 40*0 ), their path must exist in the file system
- as an object will be created from the data at the path.The handling
- now very much equals the way string paths are processed, except that
+ relative to the git repository as an object will be created from
+ the data at the path.
+ The handling now very much equals the way string paths are processed, except that
the mode you have set will be kept. This allows you to create symlinks
by settings the mode respectively and writing the target of the symlink
directly into the file. This equals a default Linux-Symlink which
@@ -945,6 +946,7 @@ class IndexFile(LazyMixin, diff.Diffable):
is not identical to the layout of the actual files on your hard-dist.
If not None and ``items`` contain plain paths, these paths will be
converted to Entries beforehand and passed to the path_rewriter.
+ Please note that entry.path is relative to the git repository.
:return:
List(BaseIndexEntries) representing the entries just actually added.
@@ -962,8 +964,9 @@ class IndexFile(LazyMixin, diff.Diffable):
if paths and path_rewriter:
for path in paths:
- abspath = os.path.join(self.repo.working_tree_dir, path)
- blob = Blob(self.repo, Blob.NULL_HEX_SHA, os.stat(abspath).st_mode, path)
+ abspath = os.path.abspath(path)
+ gitrelative_path = abspath[len(self.repo.working_tree_dir)+1:]
+ blob = Blob(self.repo, Blob.NULL_HEX_SHA, os.stat(abspath).st_mode, gitrelative_path)
entries.append(BaseIndexEntry.from_blob(blob))
# END for each path
del(paths[:])
@@ -1197,8 +1200,6 @@ class IndexFile(LazyMixin, diff.Diffable):
return out
-
-
@default_index
def commit(self, message, parent_commits=None, head=True):
"""
diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py
index 4a0e278d..826f684c 100644
--- a/lib/git/objects/commit.py
+++ b/lib/git/objects/commit.py
@@ -357,9 +357,9 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable):
try:
repo.head.commit = new_commit
except ValueError:
- # head is not yet set to master - create it and set it
+ # head is not yet set to the ref our HEAD points to.
import git.refs
- master = git.refs.Head.create(repo, 'master', commit=new_commit)
+ master = git.refs.Head.create(repo, repo.head.ref, commit=new_commit)
repo.head.reference = master
# END handle empty repositories
# END advance head handling
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 4ab656c4..396dd129 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -526,7 +526,7 @@ class Repo(object):
default_args = ('--abbrev=40', '--full-index', '--raw')
if index:
# diff index against HEAD
- if os.path.isfile(self.index.path) and \
+ if os.path.isfile(self.index.path) and self.head.is_valid() and \
len(self.git.diff('HEAD', '--cached', *default_args)):
return True
# END index handling