- conflicts_file = os.path.join(basedir.get(), 'conflicts')
- if os.path.isfile(conflicts_file):
- f = file(conflicts_file)
- names = [line.strip() for line in f.readlines()]
- f.close()
- return names
- else:
- return None
-
-def _input(cmd, file_desc):
- p = popen2.Popen3(cmd, True)
- while True:
- line = file_desc.readline()
- if not line:
- break
- p.tochild.write(line)
- p.tochild.close()
- if p.wait():
- raise GitException, '%s failed (%s)' % (' '.join(cmd),
- p.childerr.read().strip())
-
-def _input_str(cmd, string):
- p = popen2.Popen3(cmd, True)
- p.tochild.write(string)
- p.tochild.close()
- if p.wait():
- raise GitException, '%s failed (%s)' % (' '.join(cmd),
- p.childerr.read().strip())
-
-def _output(cmd):
- p=popen2.Popen3(cmd, True)
- output = p.fromchild.read()
- if p.wait():
- raise GitException, '%s failed (%s)' % (' '.join(cmd),
- p.childerr.read().strip())
- return output
-
-def _output_one_line(cmd, file_desc = None):
- p=popen2.Popen3(cmd, True)
- if file_desc != None:
- for line in file_desc:
- p.tochild.write(line)
- p.tochild.close()
- output = p.fromchild.readline().strip()
- if p.wait():
- raise GitException, '%s failed (%s)' % (' '.join(cmd),
- p.childerr.read().strip())
- return output
-
-def _output_lines(cmd):
- p=popen2.Popen3(cmd, True)
- lines = p.fromchild.readlines()
- if p.wait():
- raise GitException, '%s failed (%s)' % (' '.join(cmd),
- p.childerr.read().strip())
- return lines
-
-def __run(cmd, args=None):
- """__run: runs cmd using spawnvp.
-
- Runs cmd using spawnvp. The shell is avoided so it won't mess up
- our arguments. If args is very large, the command is run multiple
- times; args is split xargs style: cmd is passed on each
- invocation. Unlike xargs, returns immediately if any non-zero
- return code is received.
+ names = []
+ for line in GRun('ls-files', '-z', '--unmerged'
+ ).raw_output().split('\0')[:-1]:
+ stat, path = line.split('\t', 1)
+ # Look for entries in stage 2 (could equally well use 3)
+ if stat.endswith(' 2'):
+ names.append(path)
+ return names
+
+def exclude_files():
+ files = [os.path.join(basedir.get(), 'info', 'exclude')]
+ user_exclude = config.get('core.excludesfile')
+ if user_exclude:
+ files.append(user_exclude)
+ return files
+
+def ls_files(files, tree = None, full_name = True):
+ """Return the files known to GIT or raise an error otherwise. It also
+ converts the file to the full path relative the the .git directory.