MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / status

Function status

src/api/status.js:57–180  ·  view source on GitHub ↗
({
  fs: _fs,
  dir,
  gitdir = join(dir, '.git'),
  filepath,
  cache = {},
  refresh = true,
})

Source from the content-addressed store, hash-verified

55 *
56 */
57export async function status({
58 fs: _fs,
59 dir,
60 gitdir = join(dir, '.git'),
61 filepath,
62 cache = {},
63 refresh = true,
64}) {
65 try {
66 assertParameter('fs', _fs)
67 assertParameter('gitdir', gitdir)
68 assertParameter('filepath', filepath)
69
70 const fs = new FileSystem(_fs)
71 const updatedGitdir = await discoverGitdir({ fsp: fs, dotgit: gitdir })
72 const ignored = await GitIgnoreManager.isIgnored({
73 fs,
74 gitdir: updatedGitdir,
75 dir,
76 filepath,
77 })
78 if (ignored) {
79 return 'ignored'
80 }
81 const headTree = await getHeadTree({ fs, cache, gitdir: updatedGitdir })
82 const treeOid = await getOidAtPath({
83 fs,
84 cache,
85 gitdir: updatedGitdir,
86 tree: headTree,
87 path: filepath,
88 })
89 const indexEntry = await GitIndexManager.acquire(
90 { fs, gitdir: updatedGitdir, cache },
91 async function (index) {
92 for (const entry of index) {
93 if (entry.path === filepath) return entry
94 }
95 return null
96 }
97 )
98 const stats = await fs.lstat(join(dir, filepath))
99
100 const H = treeOid !== null // head
101 const I = indexEntry !== null // index
102 const W = stats !== null // working dir
103
104 const getWorkdirOid = async () => {
105 if (I && !compareStats(indexEntry, stats)) {
106 return indexEntry.oid
107 } else {
108 const object = await fs.read(join(dir, filepath))
109 const workdirOid = await hashObject({
110 gitdir: updatedGitdir,
111 type: 'blob',
112 object,
113 })
114 // If the oid in the index === working dir oid but stats differed update cache

Callers 14

stashChangesFunction · 0.85
test-stash.jsFile · 0.85
test-validate.jsFile · 0.85
stashChangesFunction · 0.85
test-add.jsFile · 0.85
test-status.jsFile · 0.85
test-cherryPick.jsFile · 0.85

Calls 9

lstatMethod · 0.95
joinFunction · 0.90
assertParameterFunction · 0.90
discoverGitdirFunction · 0.90
getHeadTreeFunction · 0.85
getOidAtPathFunction · 0.85
getWorkdirOidFunction · 0.85
isIgnoredMethod · 0.80
acquireMethod · 0.80

Tested by 2

stashChangesFunction · 0.68
stashChangesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…